运行 gevent 的 WSGIServer 时,我遇到了一些非常奇怪的行为。似乎通过的每个请求的方法都被错误地解释了..
如果我发送以下请求:
requests.get('http://localhost:5000')
requests.head('http://localhost:5000')
requests.delete('http://localhost:5000')
requests.put('http://localhost:5000')
requests.post('http://localhost:5000')
这是控制台中显示的内容:
127.0.0.1 - - [2012-01-22 14:55:36] "POST / HTTP/1.1" 405 183 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:41] "DELETE / HTTP/1.1" 405 185 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:46] "16 / HTTP/1.1" 405 181 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:50] "8 / HTTP/1.1" 405 180 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:56:13] "HEAD / HTTP/1.1" 200 0 "-" "python-requests/0.9.1"
为了完整起见,这是我正在运行的脚本:
from gevent.wsgi import WSGIServer
from flask import Flask
app = Flask(__name__)
app.debug = True
@app.route("/")
def hello():
return 'hello'
port = 5000
http_server = WSGIServer(('', port), app)
http_server.serve_forever()
会发生什么?
编辑:
我正在使用 gevent 版本:0.13.0