I have vm in cloud, python 3.3 (also tried with 3.4 - same result) and Gunicorn 18. I copy/paste 'hello world' app (app.py):
def app(environ, start_response):
data = "Hello, World!\n"
start_response("200 OK", [
("Content-Type", "text/plain"),
("Content-Length", str(len(data)))
])
return iter([data])
then run
gunicorn -w 4 -b 0.0.0.0:8000 app:app
workers started without errors, but when I tried to open it with browser I get only headers with no body:
Connection: "close"
Content-Length: "14"
...and so on
If I add some custom header I'll get it in response but no response body. Please help
To add to Graham's explanation, replacing
return iter([data])
with
return [bytes(data, 'utf-8')]
works for me under Python 3. That solved the same problem when I had it too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With