Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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/ --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.

share|improve this question
up vote 1 down vote accepted

WSGI for python3 is different, your output must be bytes not string

share|improve this answer
That was it thanks! For the curious, instead of output = 'Hello World!', I did output = b'Hello World!' – Mediocre Gopher Jul 18 '12 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.