从 WSGI 访问 POST 数据 [英] Accessing POST Data from WSGI
本文介绍了从 WSGI 访问 POST 数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎无法弄清楚如何使用 WSGI 访问 POST 数据.我在 wsgi.org 网站上尝试了这个例子,但没有奏效.我现在正在使用 Python 3.0.请不要推荐 WSGI 框架,因为那不是我想要的.
I can't seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn't work. I'm using Python 3.0 right now. Please don't recommend a WSGI framework as that is not what I'm looking for.
我想弄清楚如何将它放入一个 fieldstorage 对象中.
I would like to figure out how to get it into a fieldstorage object.
推荐答案
假设您正在尝试将 POST 数据放入 FieldStorage 对象:
Assuming you are trying to get just the POST data into a FieldStorage object:
# env is the environment handed to you by the WSGI server.
# I am removing the query string from the env before passing it to the
# FieldStorage so we only have POST data in there.
post_env = env.copy()
post_env['QUERY_STRING'] = ''
post = cgi.FieldStorage(
fp=env['wsgi.input'],
environ=post_env,
keep_blank_values=True
)
这篇关于从 WSGI 访问 POST 数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文