title: Method Not Allowed with flask application in python
body: <p>I am trying to make a sign in page with flask and i keep getting this error message</p>
  <p>Method Not Allowed</p>
  <p>this is main.py</p>
  <pre><code>from flask import Flask, render_template, redirect, url_for, request
  app = Flask('app')
  
  @app.route('/login')
  def login():
      error = None
      if request.method == 'POST':
          if request.form['username'] != 'admin' or request.form['password'] != 'admin':
              error = 'Invalid Credentials. Please try again.'
          else:
              return redirect(url_for('home'))
      return render_template('login.html', error=error)
  @app.route('/home')
  def home():
    return &quot;home&quot;
  
  app.run(host='0.0.0.0', port=8080)
  </code></pre>
  <p>this is templates/login.html</p>
  <pre><code>  &lt;head&gt;
      &lt;title&gt;Flask Intro - login page&lt;/title&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;link href=&quot;static/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; media=&quot;screen&quot;&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class=&quot;container&quot;&gt;
        &lt;h1&gt;Please login&lt;/h1&gt;
        &lt;br&gt;
        &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
          &lt;input type=&quot;text&quot; placeholder=&quot;Username&quot; name=&quot;username&quot; value=&quot;{{
            request.form.username }}&quot;&gt;
           &lt;input type=&quot;password&quot; placeholder=&quot;Password&quot; name=&quot;password&quot; value=&quot;{{
            request.form.password }}&quot;&gt;
          &lt;input class=&quot;btn btn-default&quot; type=&quot;submit&quot; value=&quot;Login&quot;&gt;
        &lt;/form&gt;
        {% if error %}
          &lt;p class=&quot;error&quot;&gt;&lt;strong&gt;Error:&lt;/strong&gt; {{ error }}
        {% endif %}
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>How can I fix this?</p>