gpt4 book ai didi

python - 从 WSGI 访问 POST 数据

转载 作者:IT老高 更新时间:2023-10-28 21:51:21 26 4
gpt4 key购买 nike

我似乎无法弄清楚如何使用 WSGI 访问 POST 数据。我在 wsgi.org 网站上尝试了该示例,但没有成功。我现在正在使用 Python 3.0。请不要推荐 WSGI 框架,因为那不是我想要的。

我想弄清楚如何将其放入字段存储对象中。

最佳答案

假设您只是尝试将 POST 数据放入 FieldStorage 对象:

# 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
)

关于python - 从 WSGI 访问 POST 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/530526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com