QuickDevGuide

Home › Flask Framework

Request & Response Handling — Flask Framework

The global request object is a proxy to the current request (thread/context local). Reading input Source Accessor Query string ?page=2 request.args.get("page", 1, type=int) Form fields request.form["email"] JSON body request.getjson() (or silent=True to return None on bad JSON) Files request.files["avatar"] Headers / cookies request.headers.get("X-Request-Id"), request.cookies Returning output A view can return a str, dict/list (auto-JSON), a Response, or a tuple (body, status, headers). Use abort(404) to stop early with an HTTP error and makeresponse() when you need to set cookies or headers.

Key Takeaways