request
flask request is the request object representing the current request, wherein a request context variable (global variable is understood to be used directly in the view of the current function can take this request)
Following common attributes:
Attributes | Explanation | Types of |
---|---|---|
data | Data recording request, and converted to a string | * |
form | Form data record request | Multidict |
args | Query parameter record request | Multidict |
cookies | cookie records information request | Dict |
headers | Record request packet header | EnvironHeaders |
method | The method of HTTP using the recording request | GET/POST |
url | URL address record request | string |
files | Record request uploaded files | * |
Examples
- Get upload images and save it to your local
@app.route('/', methods=['POST']) def index(): pic = request.files.get('pic') pic.save('./static/aaa.png') return 'index'