Hi,
You can use dedicated hooks(decorators) called before and after requests.
They are called:
Flask.before_request
Flask.after_request
@app.before_request
def do_something_whenever_a_request_comes_in():
# request is available
@app.after_request
def do_something_whenever_a_request_has_been_handled(response):
# we have a response to manipulate, always return one return response