Capture more than one value from URL with Flask/Python
<p>I want to pass values to my Python script based on what button was clicked in the HTML. I can do it like this if there is only one value:</p>

<pre><code>@app.route('/', defaults={'category': ''})
@app.route('/&lt;category&gt;')
def index(category):
</code></pre>

<p>But altogether there are 3 values what I want to capture, and I can't figure out how to do that. All of these values are optional. One (a sorting method) has a default value set, the other two are not set by default.</p>

<p>How can I make this work within a single function and 3 variables? Thanks.</p>

<p>You can set more than 1 variable in your routing/function:</p>

<pre><code>@app.route('/', defaults={'category': '', 'var2': '', 'var3': ''})
@app.route('/&lt;category&gt;/&lt;var2&gt;/&lt;var3&gt;')
def index(category, var2, var3):
</code></pre>

python flask