Method: flask.scaffold.Scaffold.after_request
Calls: 10, Exceptions: 0, Paths: 1Back
Path 1: 10 calls (1.0)
test_async_before_after_request.
test_async_before_after_request.
1@setupmethod
2 def after_request(self, f: T_after_request) -> T_after_request:
3 """Register a function to run after each request to this object.
4
5 The function is called with the response object, and must return
6 a response object. This allows the functions to modify or
7 replace the response before it is sent.
8
9 If a function raises an exception, any remaining
10 ``after_request`` functions will not be called. Therefore, this
11 should not be used for actions that must execute, such as to
12 close resources. Use :meth:`teardown_request` for that.
13
14 This is available on both app and blueprint objects. When used on an app, this
15 executes after every request. When used on a blueprint, this executes after
16 every request that the blueprint handles. To register with a blueprint and
17 execute after every request, use :meth:`.Blueprint.after_app_request`.
18 """
19 self.after_request_funcs.setdefault(None, []).append(f)
20 return f