tonysepia
tonysepia

Reputation: 3510

How to get POST variables in Python, when using gevent?

This is the question:How to get POST variables in Python, when using gevent?

The following is passed to the application:

def application(env, start_response):

And this is the other part:

if __name__ == '__main__':
print 'Serving on 8080...'
WSGIServer(('', 8080), application).serve_forever()

But env doesn't contain my POST!

Please enlighten me - where does my misunderstanding lie?

Thank you!

Upvotes: 8

Views: 1739

Answers (2)

Denis
Denis

Reputation: 3780

You need to parse the request body environ['wsgi.input'].read().

However, you're better off using a web framework to do that for you. Most of the WSGI-enabled web frameworks work well with gevent. If you need something minimal, bottle is nice.

Upvotes: 2

Ivan Kolodyazhny
Ivan Kolodyazhny

Reputation: 574

Here is example code of request handler:

def

callback(request): 
    post_data = request.input_buffer.read(-1)

Upvotes: 1

Related Questions