Domanda

Sto ottenendo un comportamento davvero strano quando gestisce il WSGISERVER di Gevent. Sembra che ogni richiesta che arriva sia interpretato in modo errato il suo metodo ..

Se invio le seguenti richieste:

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')

Questo è ciò che appare nella console:

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"

Per completezza, questa è la sceneggiatura che sto eseguendo:

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()

Cosa potrebbe succedere?

Modificare:

Sto usando la versione di Gevent: 0.13.0

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top