Trigger a function for all the endpoint ? #5114
Replies: 1 comment 1 reply
-
from flask import Flask, request
app = Flask(__name__)
@app.before_request
def before_request():
endpoints = ['/endpoint1', '/endpoint2']
if request.endpoint in endpoints:
print('Code executed for endpoint:', request.endpoint) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
BobSquarePants
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I've used before
@app.before_request
that run code before every request.If there a way to run code (once) for every endpoint only (and not every request, static files etc.. ?)
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions