Can Flask have optional URL parameters?

Is it possible to directly declare a flask URL optional parameter?

Currently I’m proceeding the following way:

@user.route('/<userId>')
@user.route('/<userId>/<username>')
def show(userId, username=None):
    pass

How can I directly say that username is optional?

11 Answers
11

Leave a Comment