flask架构中的方法学习
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from flask import Flask, render_template, jsonify, request # import flask import requests import json import config import paramiko from functools import wraps import socket import json app = Flask(__name__) @app.route('/post',methods=['POST','GET']) def post(): method = request.method #记录请求使用的HTTP方法 args = request.args #记录请求中的查询参数 data = request.data #记录请求数据,并转化为字符串 # cookie = request.cookie form = request.form url= request.url files = request.files ''' request模块学习连接https://www.jianshu.com/p/77a123482d8f 小辣椒 http://docs.jinkan.org/docs/flask/quickstart.html http://docs.jinkan.org/docs/flask/patterns/fileuploads.html#uploading-files ''' print(url) print(args) print(json.dumps(str(data))) print(request.files) print(type(request.files)) print('取值文件名方法一') print(request.files['myfile']) print(request.files['myfile'].filename) print('取值文件名方法二') f = request.files.get('file_name') print(f.filename) dict01 = dict(request.files) print(dict01['file_name']) # print((dict01['file_name'].__name__)) return (method,args) if __name__ == '__main__': app.run(host="0.0.0.0", port=8888, debug=True)