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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
腾讯CDC
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
Engineering at Meta
Engineering at Meta
C
Check Point Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 司徒正美

zplb

我发明了窝窝头文!(自然语言) - 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...
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