使用gevent时如何在Python中获取POST变量?

时间:2012-12-30 18:53:15

标签: python post gevent

这是一个问题:如何在使用gevent时获取Python中的POST变量?

以下内容传递给应用程序:

def application(env, start_response):

这是另一部分:

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

但是env不包含我的POST!

请赐教 - 我的误会在哪里?

谢谢!

2 个答案:

答案 0 :(得分:2)

您需要解析请求正文environ['wsgi.input'].read()

但是,您最好使用Web框架为您执行此操作。大多数启用了WSGI的Web框架都可以很好地与gevent配合使用。如果你需要一些最小的东西,bottle很不错。

答案 1 :(得分:1)

以下是请求处理程序的示例代码:

def

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