Create a custom URL and outputting HTML form data
<p>For my first Flask project I wanted to create a basic Flask app using Riot Game's API for League of Legends. I've got all the processing of API working but I'm having trouble going about outputting it.</p>

<p>I take the input from a form on one page.</p>

<pre><code>&lt;form class="navbar-form navbar-left" action="{{ url_for('current_game_output') }}" method="POST"&gt;
    &lt;div class="form-group"&gt;
        &lt;input type="text" class="form-control" placeholder="Summoner Name" name="summoner_name"&gt;
        &lt;select class="form-control" name="region"&gt;
            &lt;option value="oce"&gt;Oceanic&lt;/option&gt;
            &lt;option value="na"&gt;North America&lt;/option&gt;
            &lt;option value="euw"&gt;Europe West&lt;/option&gt;
        &lt;/select&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-default" value="Send"&gt;Submit&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>And I am trying to output the data returned from the API onto the next page.</p>

<pre><code>{% extends "header.html" %}
{% block body %}

    &lt;h3&gt; Team 2 &lt;/h3&gt;
    &lt;table class="table table-bordered" width="50%"&gt;
        &lt;tr&gt;
            &lt;th width="48%"&gt;Summoner Name&lt;/th&gt;
            &lt;th width="48%"&gt;Champion&lt;/th&gt;
            &lt;th width="4%"&gt;Pic&lt;/th&gt;
        &lt;/tr&gt;
        {% for player in team1 %}
            &lt;tr&gt;
                &lt;td&gt;{{ player[0] }}&lt;/td&gt;
                &lt;td&gt;{{ player[1] }}&lt;/td&gt;
                &lt;td&gt;&lt;img width="20px" src="{{ url_for('static', filename='images/championIcons/') }}{{ player[1].replace(" ", "") }}_Square_0.png"&gt;&lt;/td&gt;
            &lt;/tr&gt;
        {% endfor %}
    &lt;/table&gt;

    &lt;h3&gt; Team 1 &lt;/h3&gt;
    &lt;table class="table table-bordered" width="50%"&gt;
        &lt;tr&gt;
            &lt;th width="48%"&gt;Summoner Name&lt;/th&gt;
            &lt;th width="48%"&gt;Champion&lt;/th&gt;
            &lt;th width="4%"&gt;Pic&lt;/th&gt;
        &lt;/tr&gt;
        {% for player in team2 %}
            &lt;tr&gt;
                &lt;td&gt;{{ player[0] }}&lt;/td&gt;
                &lt;td&gt;{{ player[1] }}&lt;/td&gt;
                &lt;td&gt;&lt;img width="20px" src="{{ url_for('static', filename='images/championIcons/') }}{{ player[1].replace(" ", "") }}_Square_0.png"&gt;&lt;/td&gt;
            &lt;/tr&gt;
        {% endfor %}
    &lt;/table&gt;
{% endblock %}
</code></pre>

<p>I'd like the URL of the output page to be dynamic'/currentgame/region/username' but keep getting errors when trying to do so. </p>

<p>Relevant part of my views.py file (hidden my api key):</p>

<pre><code>@app.route('/header')
def header():
    return render_template("header.html")

@app.route('/current')
def current():
    return render_template("current.html")


@app.route('/currentgame/&lt;region&gt;/&lt;name&gt;', methods=['POST'])
def current_game_output(region, name):
    region = request.form['region']
    summoner_name = request.form['summoner_name']
    api = RiotAPI('APIKEYGOESHERE', region)
    team1, team2 = current_game_data(summoner_name, region, api)
    return render_template("output.html",team1=team1,team2=team2)
</code></pre>

<p>Any help/pointers on the best way to output/return the data would be appreciated.
Thanks</p>

<p>You should post the error as well.</p>

<p>In a quick looks this should be fixed:</p>

<pre><code>@app.route('/currentgame/&lt;string:region&gt;/&lt;string:name&gt;', methods=['POST'])
def current_game_output(region, name):
    region = request.form['region']
    summoner_name = request.form['summoner_name']
    api = RiotAPI('APIKEYGOESHERE', region)
    team1, team2 = current_game_data(summoner_name, region, api)
    return render_template("output.html",team1=team1,team2=team2) 
</code></pre>

<p>Change route to <code>/currentgame/&lt;string:region&gt;/&lt;string:name&gt;</code></p>

python forms python-3.x flask