0

I have a flask method/view which has to be executed for multiple routes. I dont need the values of url as a variable. I just need to route multiple url to same method without stacking up app.routes for each urls.

I tried AnyConverter in app.routes but its not working fine.

Tried AnyConverter:

@app.route('/<any(/something/some):segment>' , methods=('POST','GET') )
def postbacks():
   ......

presently my code looks

@app.route('/something0/z',methods=('POST','GET'))
@app.route('/something1/a',methods=('POST','GET'))
@app.route('/something2/b',methods=('POST','GET'))
@app.route('/something3/c', methods=('POST','GET'))
def postbacks():
     ......

I have all the list of routes in a list. How to use anyconverter to include a list of routes to a same method.

Sathyan A
  • 9
  • 3
  • Hello! see if the answer on this link does it for you. https://stackoverflow.com/questions/14023664/flask-url-route-route-several-urls-to-the-same-function – Mahmud Alptekin Aug 26 '22 at 14:08
  • @MahmudAlptekin No I dont want like that. I want to use anyconverter you gave a link for int converter – Sathyan A Aug 30 '22 at 05:15
  • Oh my bad! I hope this is more helpful: https://stackoverflow.com/questions/43012860/pass-in-a-list-of-possible-routes-to-flask – Mahmud Alptekin Aug 30 '22 at 08:04
  • @MahmudAlptekin can you mark it not duplicate as the link you gave now is already referred by me and it's not working. That's why I ask this question that any convertor is not working as expected. – Sathyan A Aug 30 '22 at 17:42
  • I wasn’t the one that closed the question. I’m assuming it was done by a mod. So if you want it reopened you should get in contact with someone like that. – Mahmud Alptekin Aug 30 '22 at 18:00

0 Answers0