MCPcopy
hub / github.com/pallets/flask / dispatch_request

Method dispatch_request

src/flask/app.py:879–902  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

877 )
878
879 def dispatch_request(self) -> ft.ResponseReturnValue:
880 """Does the request dispatching. Matches the URL and returns the
881 return value of the view or error handler. This does not have to
882 be a response object. In order to convert the return value to a
883 proper response object, call :func:`make_response`.
884
885 .. versionchanged:: 0.7
886 This no longer does the exception handling, this code was
887 moved to the new :meth:`full_dispatch_request`.
888 """
889 req = request_ctx.request
890 if req.routing_exception is not None:
891 self.raise_routing_exception(req)
892 rule: Rule = req.url_rule # type: ignore[assignment]
893 # if we provide automatic options for this URL and the
894 # request came with the OPTIONS method, reply automatically
895 if (
896 getattr(rule, "provide_automatic_options", False)
897 and req.method == "OPTIONS"
898 ):
899 return self.make_default_options_response()
900 # otherwise dispatch to the handler for that endpoint
901 view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
902 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
903
904 def full_dispatch_request(self) -> Response:
905 """Dispatches the request and on top of that performs request

Callers 1

full_dispatch_requestMethod · 0.95

Calls 3

ensure_syncMethod · 0.95

Tested by

no test coverage detected