dispatch_request() — flask Function Reference
Architecture documentation for the dispatch_request() function in app.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 59b4fb78_3cac_a043_29b8_6e0b8103b575["dispatch_request()"] 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5["Flask"] 59b4fb78_3cac_a043_29b8_6e0b8103b575 -->|defined in| 9f8cc56e_d5c4_e7a8_438a_3124c0dd5de5 4deafda5_fb07_c30c_ad12_a72767b1a116["full_dispatch_request()"] 4deafda5_fb07_c30c_ad12_a72767b1a116 -->|calls| 59b4fb78_3cac_a043_29b8_6e0b8103b575 ed42e052_3b19_c965_f4bb_2b6c30bb3cbc["raise_routing_exception()"] 59b4fb78_3cac_a043_29b8_6e0b8103b575 -->|calls| ed42e052_3b19_c965_f4bb_2b6c30bb3cbc 660830f4_3e12_2ae6_d646_2f7c6dd85505["make_default_options_response()"] 59b4fb78_3cac_a043_29b8_6e0b8103b575 -->|calls| 660830f4_3e12_2ae6_d646_2f7c6dd85505 a89c0022_4807_bf16_9be1_6a66f3c78c9f["ensure_sync()"] 59b4fb78_3cac_a043_29b8_6e0b8103b575 -->|calls| a89c0022_4807_bf16_9be1_6a66f3c78c9f style 59b4fb78_3cac_a043_29b8_6e0b8103b575 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/flask/app.py lines 965–989
def dispatch_request(self, ctx: AppContext) -> ft.ResponseReturnValue:
"""Does the request dispatching. Matches the URL and returns the
return value of the view or error handler. This does not have to
be a response object. In order to convert the return value to a
proper response object, call :func:`make_response`.
.. versionchanged:: 0.7
This no longer does the exception handling, this code was
moved to the new :meth:`full_dispatch_request`.
"""
req = ctx.request
if req.routing_exception is not None:
self.raise_routing_exception(req)
rule: Rule = req.url_rule # type: ignore[assignment]
# if we provide automatic options for this URL and the
# request came with the OPTIONS method, reply automatically
if (
getattr(rule, "provide_automatic_options", False)
and req.method == "OPTIONS"
):
return self.make_default_options_response(ctx)
# otherwise dispatch to the handler for that endpoint
view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does dispatch_request() do?
dispatch_request() is a function in the flask codebase, defined in src/flask/app.py.
Where is dispatch_request() defined?
dispatch_request() is defined in src/flask/app.py at line 965.
What does dispatch_request() call?
dispatch_request() calls 3 function(s): ensure_sync, make_default_options_response, raise_routing_exception.
What calls dispatch_request()?
dispatch_request() is called by 1 function(s): full_dispatch_request.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free