Can an endpoint ignore the 'after request' decorator in Flask?

Viewed 493

If I have a function

@app.after_request
def foo():
    ....

which is used after almost every request, but not for some, can I ignore the above for some requests?

1 Answers

You can try something like this -

@app.after_request
def foo():
    if request.endpoint != 'endpoint' :
        .... your code
    else:
        return

Here replace 'endpoint' with the endpoints you want to skip

Related