I have a Flask web page that is using a library that do not load properly when the Flask decorator '@app.after_request' is used. Is there a way to disable that decorator only for certain pages?
CodePudding user response:
You could make your own decorator function that checks for the request path or just check in another function.
@app.route('/whatever/path')
def check_func():
if request.path == "doesn't/work":
return view_func()
else:
return app.after_request(view_func)
I'm not sure if this is best practice.
CodePudding user response:
@app.after_request
def myAfterRequest():
if ( request.path == 'path/to/exclude' ):
return
#decorator code
return