Skip to main content

Request

The request object used by default in Flask. Remembers the matched endpoint and view arguments.

Attributes

AttributeTypeDescription
json_modulet.Any = jsonThe module used for serialization and deserialization of JSON data within the request.
url_rule`RuleNone` = None
view_args`dict[str, t.Any]None` = None
routing_exception`HTTPExceptionNone` = None

Constructor

Signature

def Request()

Methods


max_content_length()

@classmethod
def max_content_length() - > int | None

The maximum number of bytes that will be read during this request. If this limit is exceeded, a 413 :exc:~werkzeug.exceptions.RequestEntityTooLarge error is raised. If it is set to None, no limit is enforced at the Flask application level. However, if it is None and the request has no Content-Length header and the WSGI server does not indicate that it terminates the stream, then no data is read to avoid an infinite stream.

Returns

TypeDescription
`intNone`

max_content_length()

@classmethod
def max_content_length(
value: int | None
) - > None

Sets the maximum number of bytes that will be read during this specific request.

Parameters

NameTypeDescription
value`intNone`

Returns

TypeDescription
Nonenull

max_form_memory_size()

@classmethod
def max_form_memory_size() - > int | None

The maximum size in bytes any non-file form field may be in a multipart/form-data body. If this limit is exceeded, a 413 :exc:~werkzeug.exceptions.RequestEntityTooLarge error is raised. If it is set to None, no limit is enforced at the Flask application level.

Returns

TypeDescription
`intNone`

max_form_memory_size()

@classmethod
def max_form_memory_size(
value: int | None
) - > None

Sets the maximum size in bytes any non-file form field may be for this specific request.

Parameters

NameTypeDescription
value`intNone`

Returns

TypeDescription
Nonenull

max_form_parts()

@classmethod
def max_form_parts() - > int | None

The maximum number of fields that may be present in a multipart/form-data body. If this limit is exceeded, a 413 :exc:~werkzeug.exceptions.RequestEntityTooLarge error is raised. If it is set to None, no limit is enforced at the Flask application level.

Returns

TypeDescription
`intNone`

max_form_parts()

@classmethod
def max_form_parts(
value: int | None
) - > None

Sets the maximum number of fields allowed in a multipart form body for this specific request.

Parameters

NameTypeDescription
value`intNone`

Returns

TypeDescription
Nonenull

endpoint()

@classmethod
def endpoint() - > str | None

The endpoint that matched the request URL. This will be None if matching failed or has not been performed yet.

Returns

TypeDescription
`strNone`

blueprint()

@classmethod
def blueprint() - > str | None

The registered name of the current blueprint. This will be None if the endpoint is not part of a blueprint, or if URL matching failed or has not been performed yet.

Returns

TypeDescription
`strNone`

blueprints()

@classmethod
def blueprints() - > list[str]

The registered names of the current blueprint upwards through parent blueprints. This will be an empty list if there is no current blueprint, or if URL matching failed.

Returns

TypeDescription
list[str]A list of blueprint names from the current one up to the root.

on_json_loading_failed()

@classmethod
def on_json_loading_failed(
e: ValueError | None
) - > t.Any

Handles failures during JSON parsing. In debug mode, it re-raises the original exception to provide a detailed traceback.

Parameters

NameTypeDescription
e`ValueErrorNone`

Returns

TypeDescription
t.AnyThe result of the parent class's failure handler, or raises a BadRequest exception.