Request & Response
The request object wraps everything about the current HTTP request, and a view's return value is converted by Flask into a response object. Understanding both ends is the core of writing web applications.
The Request Object
flask.request is a context-safe proxy you import and use directly inside views:
Common attributes:
Forms and JSON
request.get_json() requires Content-Type: application/json by default, raising 415 otherwise.
File Uploads
Remember to cap upload size: app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024 (excess returns 413 automatically).
The Many Forms of Responses
View return values are wrapped by Flask automatically:
Fine-Grained Control: make_response
When you need headers, cookies, etc., build the response object explicitly:
Redirects and File Downloads
Request Hooks
Insert logic into the request lifecycle: