title: Flask - POST Error 405 Method Not Allowed
body: <p>I'm just starting to learn Flask, and I am trying to create a form which will allow a <strong>POST</strong> method.</p>
  
  <p>Here's my method:</p>
  
  <pre><code>@app.route('/template', methods=['GET', 'POST'])
  def template():
      if request.method == 'POST':
          return("Hello")
      return render_template('index.html')
  </code></pre>
  
  <p>And my <code>index.html</code>:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;head&gt;
    &lt;title&gt; Title &lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    Enter Python to execute:
    &lt;form action="/" method="post"&gt;
      &lt;input type="text" name="expression" /&gt;
      &lt;input type="submit" value="Execute" /&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Loading the form (rendering it when it receives <strong>GET</strong>) works fine. When I click on the <strong>submit</strong> button however, I get a <code>POST 405 error Method Not Allowed</code>.</p>
  
  <p>Why isn't it displaying <strong>"Hello"</strong>?</p>