title: Flask - Routing with multiple optional parameters
body: <p>I have a Route named search: @app.route('/search')
  Is it possible to add multiple optional parameters to it? Example:</p>
  
  <pre><code>@app.route('/search/pg/&lt;int:pg&gt;')
  @app.route('/search/types/&lt;types&gt;')
  @app.route('/search/number/&lt;int:number&gt;')
  @app.route('/search/subject/&lt;subject&gt;')
  </code></pre>
  
  <p>The order in the URL shouldnt matter, so I could call /search/pg/2, or /search/subject/MySubject/pg/2 or /search/types/posts/subject/MySubject/pg/2</p>
  
  <p>I tried this, but it only works with the full paths and all the parameters:</p>
  
  <pre><code>@app.route('/search/pg/&lt;int:pg&gt;/types/&lt;types&gt;/subject/&lt;subject&gt;', methods=['GET', 'POST'])
  @app.route('/search/subject', defaults={'subject', None})
  @app.route('/search/pg/&lt;int:pg&gt;/types/&lt;types&gt;', methods=['GET', 'POST'])
  @app.route('/search/types', defaults={'types', None})
  @app.route('/search', defaults={'pg': 1}, methods=['GET', 'POST'])
  @app.route('/search/pg/&lt;int:pg&gt;', methods=['GET', 'POST'])
  def search(pg, types=None, subject=None):
      pass
  </code></pre>