Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
1  
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

 
discard

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.