Method Not Allowed. Flask receives GET instead of POST
<p>I'm trying to get used to the Flask API and I'm creating a simple page with 1 form which uses POST method. </p>

<p>Instead when I look at the Flask output I can see that any time I try to open the /configure view Flask receives a GET method instead and returns Method not allowed on the view.</p>

<p>test.py - </p>

<pre><code>from flask import Flask, request, session, g, redirect, url_for, \
    abort, render_template, flash
import dude

app = Flask(__name__)


@app.route('/')
def hello():
    output = None
    if retval:
        output = "True"
    elif retval == False:
        output = "False" + error
    return render_template('index.html', output=output)

@app.route('/configure', methods=['POST'])
def configure():
    hostname = request.form['hostname']
    if hostname in ip_dict:
        _info.append(hostname)
        flash('good job')
    else:
        flash('Host name not in the DNS system')
    return render_template('configure.html')

if __name__== "__main__":
    WB = dude.Dude()
    retval, error, ip_dict = WB.get_ips()
    app.run(debug=True)
</code></pre>

<p>index.html</p>

<pre><code>&lt;!doctype html&gt;
&lt;title&gt;configurator&lt;/title&gt;
&lt;link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"&gt;
&lt;div class=page&gt;
    &lt;h1&gt;Configurator&lt;/h1&gt;
    &lt;div class=metanav&gt;
        &lt;p&gt;{{ output }}&lt;/p&gt;
        &lt;a href="{{ url_for('configure') }}"&gt;Configure&lt;/a&gt;
    &lt;/div&gt;
    {% for message in get_flashed_messages() %}
        &lt;div class=flash&gt;{{ message }}&lt;/div&gt;
    {% endfor %}
    {% block body %}{% endblock %}
&lt;/div&gt;
</code></pre>

<p>configure.html</p>

<pre><code>{% extends "index.html" %}
{% block body %}
    &lt;h1&gt;Configure&lt;/h1&gt;
    &lt;form action="{{ url_for('configure') }}" method=post class=hostname&gt;
    &lt;d1&gt;
        &lt;dt&gt;Host name:
        &lt;dd&gt;&lt;input type=text name=hostname size=15&gt;
        &lt;dd&gt;&lt;input type=submit value=Submit&gt;
    &lt;/d1&gt;
    &lt;/form&gt;
    {% for message in get_flashed_messages() %}
        &lt;div class=flash&gt;{{ message }}&lt;/div&gt;
    {% endfor %}
&lt;/div&gt;
{% endblock %}
</code></pre>

<p>and the console output from Flask</p>

<pre><code>127.0.0.1 - - [04/Apr/2016 19:24:25] "GET /configure HTTP/1.1" 405 -
</code></pre>

<p>UPDATE</p>

<p>I found my mistake. I am rendering template index.html in a place where I should be instead rendering configure.html. After this in configure() I am rendering a template where instead I should redirect.</p>

<p>This is how the new methods look like.</p>

<pre><code>@app.route('/')
def hello():
    output = None
    if retval:
        output = "True"
    elif retval == False:
        output = "False" + error
    return render_template('configure.html', output=output)

@app.route('/comeon', methods=['POST'])
def configure():
    hostname = request.form['hostname']
    if hostname in ip_dict:
        _info.append(hostname)
        flash('good job')
    else:
        flash('Host name not in the DNS system')
    return redirect(url_for('hello'))
</code></pre>