获取参数
data
form
args
cookie
headers
method
url
files
1.url获取参数
# 引入Flask库 from flask import Flask,request app=Flask(__name__) # 3./articles?channel_id=123 @app.route("/articles") def get_article(): ch_id=request.args.get("channel_id") return "get channel {}".format(ch_id) if __name__ == ‘__main__‘: #调试服务器 app.run()
2.上传文件
# 引入Flask库 from flask import Flask,request app=Flask(__name__) @app.route("/upload",methods=[‘POST‘]) def upload_file(): f=request.files["pic"] f.save("/demo.png") return "ok" if __name__ == ‘__main__‘: #调试服务器 app.run()
原文:https://www.cnblogs.com/hapyygril/p/14945825.html