So I'm using Flask and Twilio's Whatsapp API and I want to have a list of all the routes. The usual code is:
@app.route("/whatever", methods=['GET', 'POST'])
def func():
<Other Stuff>
But I would like something like this
routes = ['route1', 'route2' , 'route3']
for i in routes:
@app.route("/"+i, methods=['GET', 'POST'])
def func():
<Other Stuff>
But when I run it, it doesn't work because the same function is being defined multiple times. Is there a work-around for this. I am new to coding and Python so any help is appreciated!