flask 获取参数2
获取参数
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()
posted on 2021-06-28 18:40 happygril3 阅读(20) 评论(0) 编辑 收藏 举报