emmett
emmett copied to clipboard
Routing with conditional parameter
Hi @gi0baro . The following works fine (for docs)
@mymodule.route("/profile(/<int:user_id>)?")
def profile(user_id):
if user_id:
# get requested user
else:
# load current logged user profile
But if I want to use it in the home of the module, it fails:
@mymodule.route("/(<int:user_id>)?")
def index(user_id):
if user_id:
# get requested user
else:
# load current logged user profile
http://127.0.0.1:8000/mymodule/ or http://127.0.0.1:8000/mymodule/1 I get Resource not found
Jose
@mymodule.route("(/<int:user_id>)?")
def index(user_id):
if user_id:
# get requested user
else:
# load current logged user profile
Thanks @tweenietomatoes, but I still get Resource not found
@josejachuf this is probably a bug regarding conditional parameters and first component of the route url. I will need to inspect this. Will update you.
hi @gi0baro Is this bug resolved?
@gaytomycode this was reported before 2.0, it needs to be verified