有如下测试代码
- test.py
#!/usr/bin/python
def application(env, start_response):
start_response('200 OK', [('Content_Type', 'text/html')])
return "Congraduation!!! uWSGI Testing OK!!!"
- 以uwsgi方式启动
uwsgi -s :8080 --wsgi-file test.py -M -p 20
- 访问
在浏览器输入http://0.0.0.0:8080/ 浏览器提示"未收到数据",后台出现错误提示
invalid request block size: 21573 (max 4096)...skip
- 错误原因
usgi参数-s表示以socket方式提供通信端口,默认的协议是tcp.
通过浏览器访问使用的协议是http.
- 正确方式
* 直接提供http服务
uwsgi --http :8080 --wsgi-file test.py -M -p 20
* ngix+uwsgi
通过nginx访问uwsgi,uwsgi则可使用以下方式启动
uwsgi -s :8080 --wsgi-file test.py -M -p 20