title: Flask routing by username at top-level route
body: <p>Is there a prefered way of setting up Flask so that it routes by username (<code>mysite.com/&lt;username&gt;</code>) at the top level but still works well (and fast) for all other routes and static files?</p>
  <p>The way I imagine it now is something like:</p>
  <pre><code>@app.route('/&lt;username&gt;', 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')
  </code></pre>
  <p>But would that have any unwanted effects on other routes or static assets, favicons, or something that I'm forgetting?</p>