Reputation: 481
I am facing a routing problem in my flask application.
The routes are defined as below
@app.route("/<lang>/books/<name>.html")
def func1(lang="en", name="")
pass
@app.route("/<lang>/books/index.html")
def func2(lang="en"):
pass
So, if a url is requested like /en/books/index.html - it should route to 2nd function, but flask routes it to first function.
Why it is so?? I also changed the order of code by placing func2 above to func1 and still facing the same issue, can i know how to resolve it.
Upvotes: 3
Views: 687
Reputation: 1607
How about this?
@app.route("/<lang>/books/<name>.html")
def func1(lang="en", name=""):
if name == "index":
return index()
return something_else()
Upvotes: 2