Method: flask.app.Flask.dispatch_request
Calls: 421, Exceptions: 111, Paths: 4Back
Path 1: 368 calls (0.87)
None (79) Response (41) '' (19) 'GET' (17) ('', 204) (12) 'POST' (11) '3' (9) 'dcba' (9) '\n Success!\n' (9) 'Hello World' (7)
Forbidden (16) ZeroDivisionError (10) InternalServerError (9) BadRequest (6) KeyError (5) Exception (3) NotFound (3) BadRequestKeyError (3) Custom (3)...
1def dispatch_request(self) -> ft.ResponseReturnValue:
2 """Does the request dispatching. Matches the URL and returns the
3 return value of the view or error handler. This does not have to
4 be a response object. In order to convert the return value to a
5 proper response object, call :func:`make_response`.
6
7 .. versionchanged:: 0.7
8 This no longer does the exception handling, this code was
9 moved to the new :meth:`full_dispatch_request`.
10 """
11 req = request_ctx.request
12 if req.routing_exception is not None:
13 self.raise_routing_exception(req)
14 rule: Rule = req.url_rule # type: ignore[assignment]
15 # if we provide automatic options for this URL and the
16 # request came with the OPTIONS method, reply automatically
17 if (
18 getattr(rule, "provide_automatic_options", False)
19 and req.method == "OPTIONS"
20 ):
21 return self.make_default_options_response()
22 # otherwise dispatch to the handler for that endpoint
23 view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
24 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
Path 2: 33 calls (0.08)
MethodNotAllowed (15) NotFound (14) RequestRedirect (2) FormDataRoutingRedirect (1) BadHost (1)
1def dispatch_request(self) -> ft.ResponseReturnValue:
2 """Does the request dispatching. Matches the URL and returns the
3 return value of the view or error handler. This does not have to
4 be a response object. In order to convert the return value to a
5 proper response object, call :func:`make_response`.
6
7 .. versionchanged:: 0.7
8 This no longer does the exception handling, this code was
9 moved to the new :meth:`full_dispatch_request`.
10 """
11 req = request_ctx.request
12 if req.routing_exception is not None:
13 self.raise_routing_exception(req)
14 rule: Rule = req.url_rule # type: ignore[assignment]
15 # if we provide automatic options for this URL and the
16 # request came with the OPTIONS method, reply automatically
17 if (
18 getattr(rule, "provide_automatic_options", False)
19 and req.method == "OPTIONS"
20 ):
21 return self.make_default_options_response()
22 # otherwise dispatch to the handler for that endpoint
23 view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
24 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
Path 3: 10 calls (0.02)
Response (10)
1def dispatch_request(self) -> ft.ResponseReturnValue:
2 """Does the request dispatching. Matches the URL and returns the
3 return value of the view or error handler. This does not have to
4 be a response object. In order to convert the return value to a
5 proper response object, call :func:`make_response`.
6
7 .. versionchanged:: 0.7
8 This no longer does the exception handling, this code was
9 moved to the new :meth:`full_dispatch_request`.
10 """
11 req = request_ctx.request
12 if req.routing_exception is not None:
13 self.raise_routing_exception(req)
14 rule: Rule = req.url_rule # type: ignore[assignment]
15 # if we provide automatic options for this URL and the
16 # request came with the OPTIONS method, reply automatically
17 if (
18 getattr(rule, "provide_automatic_options", False)
19 and req.method == "OPTIONS"
20 ):
21 return self.make_default_options_response()
22 # otherwise dispatch to the handler for that endpoint
23 view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
24 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
Path 4: 10 calls (0.02)
'bar' (3) 'GET' (2) 'index' (2) 'HEAD' (1) 'POST' (1) '7eb41166-9ebf-4d26-b771-ea3f54f8b383' (1)
1def dispatch_request(self) -> ft.ResponseReturnValue:
2 """Does the request dispatching. Matches the URL and returns the
3 return value of the view or error handler. This does not have to
4 be a response object. In order to convert the return value to a
5 proper response object, call :func:`make_response`.
6
7 .. versionchanged:: 0.7
8 This no longer does the exception handling, this code was
9 moved to the new :meth:`full_dispatch_request`.
10 """
11 req = request_ctx.request
12 if req.routing_exception is not None:
13 self.raise_routing_exception(req)
14 rule: Rule = req.url_rule # type: ignore[assignment]
15 # if we provide automatic options for this URL and the
16 # request came with the OPTIONS method, reply automatically
17 if (
18 getattr(rule, "provide_automatic_options", False)
19 and req.method == "OPTIONS"
20 ):
21 return self.make_default_options_response()
22 # otherwise dispatch to the handler for that endpoint
23 view_args: dict[str, t.Any] = req.view_args # type: ignore[assignment]
24 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)