Skip to main content
Flask’s request object is available in any route function. Import it from flask:

JSON body

For POST, PUT, and PATCH requests with a JSON body:
request.get_json() parses the body and returns a dict. If the body is missing or not valid JSON it returns None. Validate the data in the service layer, not the route.

Query parameters

request.args is an ImmutableMultiDict. Use .get(key, default, type=) to safely read values with type coercion.

Headers

Headers are read in the token_required decorator — routes generally don’t need to read headers directly.

URL path parameters

Flask supports dynamic URL segments using <variable>:
Supported converters: string (default), int, float, path, uuid.

Form data

File uploads

Request validation pattern

Validate request data in the service using marshmallow schemas:
See Schemas for full details.