Skip to main content

after_this_request

Decorate a function to run after the current request. The behavior is the same as :meth:.Flask.after_request, except it only applies to the current request, rather than every request. Therefore, it must be used within a request context, rather than during setup.

def after_this_request(
f: ft.AfterRequestCallable[t.Any]
) - > ft.AfterRequestCallable[t.Any]

Decorate a function to run after the current request. The behavior is the same as :meth:.Flask.after_request, except it only applies to the current request, rather than every request. Therefore, it must be used within a request context, rather than during setup.

Parameters

NameTypeDescription
fft.AfterRequestCallable[t.Any]The function to be executed after the current request is processed; it must accept a response object and return a response object.

Returns

TypeDescription
ft.AfterRequestCallable[t.Any]The decorated function, allowing it to be used as a decorator or called directly.