写了一个极简单的 web server ,支持:
- 静态文件(相当于标准库 SimpleHTTPServer )
- WSGI 应用 (简单的 WSGI Server )
- 代理到其他 web 服务
- 多线程 /多进程处理请求
## 代码 ##
[
https://github.com/RealHacker/python-gems/tree/master/http_server](
https://github.com/RealHacker/python-gems/tree/master/http_server)
## 配置文件 ##
{
"server":{
"ip": "127.0.0.1",
"port": 8000,
"mode": "thread"
},
"routes":{
"/app": {
"type": "wsgi",
"application": "D:/Workspace/Example/
wsgi.py"
},
"/app/static": {
"type": "static",
"dir": "D:/workspace/static/"
},
"/app/proxy": {
"type": "proxy",
"proxyurl": "
http://www.qq.com/"
}
}
}
设置好 config.json 后,即可执行:
python
web_server.py这个是自己写的原型,所以一定有很多没考虑到的问题,希望有兴趣的可以帮忙跑一下,看看有什么 bug ,或者直接点评代码。良辰在此先行谢过。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://v2ex.xtra.eu.org/t/224349
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.