提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
一、Flask中request其它参数,含请求头Headers,及method参数的获取
代码如下(示例):
from flask import Flask,request
app = Flask(__name__)
@app.route('/args',methods=['GET','POST'])
def args():
url = request.url
method = request.method
headers = request.headers.get('Content-Type')
user_agent = request.headers.get('User-Agent')
uid = request.cookies.get('uid')
return f'Hello=={url} == {method} =={headers} =={user_agent}=={uid}'
if __name__ =='__main__':
app.run(debug=True)