1
運行gevent的WSGIServer時,出現了一些非常奇怪的行爲。似乎每次自帶通過具有被錯誤解釋它的方法請求..gevent.WSGIServer請求方法mystery
如果我發送了以下請求:
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
我使用安裝使用apt-get的gevent版本0.13.0。使用'pywsgi'解決了這個問題,但是我很好奇爲什麼當使用'gevent.wsgi'時爲什麼會出錯。 – Acorn
ubuntu存儲庫有一個gevent的古老版本。升級到最新版本將所有內容整理出來。乾杯! – Acorn