How to get POST variables in Python when using gevent?

The question arises: 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 does not contain my POST!

Please enlighten me - where is my misunderstanding?

Thanks!

+7
source share
2 answers

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

However, you better use the web infrastructure for this. Most web frameworks that support WSGI work well with gevent. If you need something minimal, bottle is nice.

+2
source

Here is a sample request handler code:

def

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

All Articles