Register a function to run after each request to this object. The function is called with the response object, and must return a response object. This allows the functions to modify or replace the response before it is sent. If a function raises an exception, any re
(self, f: T_after_request)
| 485 | |
| 486 | @setupmethod |
| 487 | def after_request(self, f: T_after_request) -> T_after_request: |
| 488 | """Register a function to run after each request to this object. |
| 489 | |
| 490 | The function is called with the response object, and must return |
| 491 | a response object. This allows the functions to modify or |
| 492 | replace the response before it is sent. |
| 493 | |
| 494 | If a function raises an exception, any remaining |
| 495 | ``after_request`` functions will not be called. Therefore, this |
| 496 | should not be used for actions that must execute, such as to |
| 497 | close resources. Use :meth:`teardown_request` for that. |
| 498 | |
| 499 | This is available on both app and blueprint objects. When used on an app, this |
| 500 | executes after every request. When used on a blueprint, this executes after |
| 501 | every request that the blueprint handles. To register with a blueprint and |
| 502 | execute after every request, use :meth:`.Blueprint.after_app_request`. |
| 503 | """ |
| 504 | self.after_request_funcs.setdefault(None, []).append(f) |
| 505 | return f |
| 506 | |
| 507 | @setupmethod |
| 508 | def teardown_request(self, f: T_teardown) -> T_teardown: |
nothing calls this directly
no test coverage detected