I've just started with wsgi and am trying to get a simple uwsgi server up and running. I've set up a virtualenv environment and activated it. Inside lib I have a file hello.py with the contents:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
And I'm running:
uwsgi --http :8000 --wsgi-file lib/hello.py --add-header "X-test: hi"
to start the server.
My problem is that the server isn't sedning the body. When I curl to localhost:8000 I can see the X-test header, so I'm definitely hitting uwsgi. Additionally, if I change "200 OK" to something else I can see that in curl as well.
I'm fairly sure I followed the tutorial correctly (it seemed pretty straightforward), can anyone spot what I'm doing wrong? Could it be that I'm using python3? I installed uwsgi through pip inside my virtualenv, if that matters at all.
WSGI for python3 is different, your output must be bytes not string