gpt4 book ai didi

python - flask 如何获取请求的 HTTP_ORIGIN

转载 作者:太空狗 更新时间:2023-10-30 00:29:40 27 4
gpt4 key购买 nike

我想用我自己设置的“Access-Control-Allow-Origin” header 做出响应,而弄清楚请求随附的“HTTP_ORIGIN”参数在哪里似乎很麻烦。

最佳答案

我正在使用 flask - 0.10.1HTTP_ORIGIN 似乎是此 object 的属性之一

flask.request.environ

这是我在处理请求时从 print flask.request.environ 得到的:

{
"wsgi.multiprocess": false,
"HTTP_REFERER": "http://www.freemerce.com/product/77104116",
"SERVER_SOFTWARE": "Werkzeug/0.9.6",
"SCRIPT_NAME": "",
"REQUEST_METHOD": "GET",
"PATH_INFO": "/prod/sync_req",
"HTTP_ORIGIN": "http://www.freemerce.com",
"SERVER_PROTOCOL": "HTTP/1.1",
"QUERY_STRING": "",
"werkzeug.server.shutdown": "<function shutdown_server at 0x4060e60>",
"CONTENT_LENGTH": "",
"HTTP_USER_AGENT": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36",
"HTTP_CONNECTION": "keep-alive",
"SERVER_NAME": "0.0.0.0",
"REMOTE_PORT": 53690,
"wsgi.url_scheme": "http",
"SERVER_PORT": "80",
"werkzeug.request": "<Request http://192.168.0.10/prod/sync_req [GET]>",
"wsgi.input": "<socket._fileobject object at 0x405e1d0>",
"HTTP_DNT": "1",
"HTTP_HOST": "192.168.0.10:80",
"wsgi.multithread": false,
"HTTP_ACCEPT": "*/*",
"HTTP_RA_SID": "DB52333D-20140914-070803-53c316-5f3242",
"wsgi.version": "(1, 0)",
"wsgi.run_once": false,
"HTTP_RA_VER": "2.8.7",
"wsgi.errors": "<open file <stderr>, mode 'w' at 0x7f57d074c270>",
"REMOTE_ADDR": "192.168.0.131",
"HTTP_ACCEPT_LANGUAGE": "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,ja;q=0.2,zh-TW;q=0.2",
"CONTENT_TYPE": "",
"HTTP_ACCEPT_ENCODING": "gzip, deflate, sdch"
}

关于python - flask 如何获取请求的 HTTP_ORIGIN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28448991/

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