惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

zplb

Setting Up a Minimal Public TinyProxy with Basic Authentication on CentOS How to Host a .onion Site on Your Own Computer (No VPS Required) Converting IPA to Speech Using Python Huawei Switch CLI Cheat Sheet
I Built a Web Server That Runs Python and PHP in the Same Page
2026-02-01 · via zplb

Project: DinoWebServe


Most modern web frameworks are overpowered for small tasks.

Sometimes I just want to:

  • Serve static files quickly
  • Add a tiny bit of Python logic inside HTML
  • Reuse an old PHP script
  • And not deal with routing, middleware, or deployment

So I built DinoWebServe, a minimal web server that can do all that.


Motivation

Why not just use Flask, Django, or PHP alone?

  1. Flask/Django are great — but for a quick local tool, they feel heavy.
  2. PHP alone can’t handle Python logic directly.
  3. Mixing both languages usually requires reverse proxies, separate servers, or templating hacks.

I wanted something that works immediately, is simple, and easy to hack.


Architecture Overview

  • Python backend: powered by Flask, handles dynamic .pys pages
  • PHP support: via php-cgi, works seamlessly alongside Python
  • Sandboxed execution: Python scripts run in a controlled environment
  • Static file serving: Everything under WWW/ is exposed
  • Logging: Every request is logged to log/ in JSON format

Example folder structure:


DinoWebServe/
├── DinoWebServe.py          # main server
├── config/
│   ├── config.cfg           # configuration
│   └── function.py          # utility functions
├── WWW/                     # web root
├── PHP/                     # php-cgi binary
└── log/                     # request logs

Key Features

1. Python Inside HTML

Embed Python directly in HTML:

<python>
echo("Current time: " + str(datetime.datetime.now()))
echo("Your IP: " + remote_addr())
</python>

No templates, no Jinja — pure Python execution.


2. PHP + Python Mixed Pages (.pp)

Re-use PHP and add Python logic:

<?php
echo "<h1>PHP output</h1>";
?>

<python>
echo("<p>Python timestamp: " + str(time.time()) + "</p>")
</python>

This is handy for projects with legacy PHP pages.


3. Quick Setup

Run:

python DinoWebServe.py

Open:

http://localhost

Done. No configuration headache.


4. Built-in Logging & Monitoring

Logs every request:

{
  "timestamp": "2025-01-09T10:30:45",
  "ip": "127.0.0.1",
  "method": "GET",
  "path": "/"
}

Helps debugging and auditing small apps.


Trade-offs

  • Not production-ready: It’s lightweight by design
  • Limited sandboxing: Security is reasonable for dev/testing but not enterprise
  • Mixing PHP + Python: Can get messy if overused

I consciously chose simplicity over safety and performance for personal projects and learning.


Why It’s Fun

  • Experiment with dynamic Python logic in HTML
  • Mix Python with PHP without complex setups
  • Learn server design in a minimal, understandable way
  • Rapid prototyping for small tools, testing, or teaching

Design Philosophy

  1. Control > Convention: I want to see and modify everything
  2. Minimalism > Features: Only implement what’s needed
  3. Readable Logs: Every request is transparent and inspectable
  4. Hackability: Easy to fork, tweak, and extend

Final Thoughts

Sometimes, building a smaller, hackable tool teaches more than using a massive framework.

DinoWebServe is probably a bad idea for production.

But it’s fun, surprisingly useful, and you can actually understand everything under the hood.


GitHub: https://github.com/zplbFelix/DinoWebServe