Is there a prefered way of setting up Flask so that it routes by username (mysite.com/<username>
) at the top level but still works well (and fast) for all other routes and static files?
The way I imagine it now is something like:
@app.route('/<username>', methods=['GET'])
def username_route(username):
if username_is_valid(username): # DB checks, not too fast
display_user_page(username)
render_template('user_not_found.html')
But would that have any unwanted effects on other routes or static assets, favicons, or something that I'm forgetting?