title: Program stopped working: now all I get is server errors that I don't understand
body: <p>I have been following a pretty standard intro to python and flask, I'm new to flask but have a few months coding python.</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>File "C:/Users/danny/PycharmProjects/learning_flask/venv/hello.py",
    line 26, in login
        session['username'] = request.form.get['username'] TypeError: 'method' object is not subscriptable
    127.0.0.1 - - [11/May/2019 16:45:43] "POST /login HTTP/1.1" 500 -</p>
  </blockquote>
  
  <p>I had this working, I think I made some changes to the templates and thats when it stopped working.  I've looked through stacktrace and other sources for errors, itseemsto be saying there is a problem in the login @app.route (but not helped by course where code and templates work every time!  If only the showed you some of the errors, if theres a site that does great -  would love url).</p>
  
  <pre><code>import os
  
  from flask import Flask, render_template, request, redirect, url_for, flash, make_response, session
  
  app=Flask(__name__)
  app.secret_key = "SuperSecretKey"
  
  @app.route('/login', methods=['GET','POST'])
  def login():
      error = None
      if request.method == 'POST':
      if valid_login(request.form['username'], request.form['password']):
          flash('Sucessfully logged in')
          session['username'] = request.form.get['username']
          return redirect(url_for('welcome'))
          # return redirect(url_for('help'))
      else:
          error = "There was an error with either the username or password"
          return render_template('login.html', error=error)
  
  @app.route('/logout')
  def logout():
  session.pop('username', None)
  return redirect(url_for('login'))
  
  
  @app.route('/')
  def welcome():
      if username in session:
          return render_template('welcome.html', 
          username=session['username'])
      else:
          return redirect(url_for('login'))
  
  def valid_login(username, password):
      if username == password:
          return True
      else:
          return False
  
  if __name__ == ('__main__'):
      app.run()
      app.debug=True
  </code></pre>
  
  <p>should load login page, but get server not found, and if successful allow me to get to welcome page, templates below I think they are ok tho' </p>
  
  <p>Base.html</p>
  
  <pre><code>&lt;head&gt;
      {% block head %}
      &lt;title&gt;{% block title %}{% endblock %}&lt;/title&gt;
      {% endblock %}
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;h1&gt;Lets Scamperdoodle&lt;/h1&gt;
  
  {% with messages = get_flashed_messages() %}
  
  {% if messages %}
      &lt;ul class="flashes"&gt;
          {% for message in messages %}
          &lt;li&gt;{{ message }}&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  {% endif %}
  
  {% endwith %}
  
  &lt;div id="content"&gt;
      {% block content %}{% endblock %}
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;footer&gt;
      {% block footer %}
      &amp;copy; Copyright 2019 &lt;a href="http://scamperdoodle.co.uk"&gt; Scamperdoodle&lt;/a&gt;
      {% endblock %}
  &lt;/footer&gt;
  </code></pre>
  
  <p>login.html</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block title %} Login page {% endblock %}
  
  {% block content %}
  
  &lt;form action="{{url_for('login')}}" method="POST"&gt;
  
      {% if error %}
      &lt;p style="color:red"&gt; {{ error }} &lt;/p&gt;
      {% endif %}
  
      &lt;p&gt;
          Username: &lt;input type="text" name="username" /&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          Password: &lt;input type="password" name="password" /&gt;
      &lt;/p&gt;
  
      &lt;button type="Submit"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  
  {% endblock %}
  </code></pre>