title: Flask/Python 3 internal server error 500 when posting from html form
body: <p>I'm new to Python &amp; Flask and trying to set up a very basic script that takes information submitted from a form and posts it to a new page (I know, very simple right?)</p>
  
  <p>I'm having limited success and can't figure out what the problem is here. It's working when I have 2 out of the 4 form fields selected in the python file:</p>
  
  <pre><code>name=request.form['name']
  age=request.form['age'] 
  </code></pre>
  
  <p>This works fine and does what I expect it to do - Renders the output.html page containing 'name' &amp; 'age'</p>
  
  <p>but as soon as I try to add any more, I'm getting an internal server error (500), even through I'm copying &amp; pasting the exact same code and only changing the variables (i.e 'number' &amp; 'feeling') - In both the .py file and the input &amp; output html files.</p>
  
  <p>Heres the code..</p>
  
  <p>Python code: </p>
  
  <p>(The input form is on the /input/ page. "input_1" renders the output.html file)</p>
  
  <pre><code>from flask import Flask, render_template, request, url_for, redirect
  from dbconnect import connection
  from flask_debugtoolbar import DebugToolbarExtension
  
  app = Flask(__name__)
  app.debug = True
  app.config['SECRET_KEY'] = 'kuywergiukrewgkbyuwe'
  toolbar = DebugToolbarExtension(app)
  
  app.config.update(TEMPLATES_AUTO_RELOAD = True)
  
  @app.route('/')
  def homepage():
      return render_template ("main.html")
  
  @app.route('/input/')
  def input():
      return render_template ("input.html")
  
  @app.route('/input/', methods=["POST"])
  def input_1():
      name=request.form['name']
      age=request.form['age']
      number=request.form['number']
      feeling=request.form['feeling']
  
      return render_template('output.html', name = name, age = age, number = number, feeling = feeling)
  
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p>The input.html file:</p>
  
  <p>(Contains the input form)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;devserver&lt;/title&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
          &lt;link rel="stylesheet" href="{{ url_for("static", filename="css/bootstrap.css") }}"&gt;
          &lt;link rel="shortcut icon" href="{{ url_for("static", filename="favicon.ico") }}"&gt;
      &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div class="container"&gt;
      &lt;div class="col"&gt;
  
          &lt;h2&gt;Input form&lt;/h2&gt;
          &lt;br&gt;
          &lt;div class="form-group" &gt;
              &lt;form method="post" action="{{ url_for('input') }}"&gt;
  
              &lt;label for="InputForm"&gt;Name&lt;/label&gt;
              &lt;input type="text" name="name" class="form-control"/&gt;
  
              &lt;label for="InputForm"&gt;Age&lt;/label&gt;
              &lt;input type="text" name="age" class="form-control"/&gt;
  
              &lt;label for="InputForm"&gt;Number&lt;/label&gt;
              &lt;input type="text" name="number" class="form-control"/&gt;
  
              &lt;label for="InputForm"&gt;Feeling&lt;/label&gt;
              &lt;input type="text" name="feeling" class="form-control"/&gt;
  
              &lt;br&gt;
              &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
  
              &lt;/form&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The output.html file:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;devserver&lt;/title&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
          &lt;link rel="stylesheet" href="{{ url_for("static", filename="css/bootstrap.css") }}"&gt;
          &lt;link rel="shortcut icon" href="{{ url_for("static", filename="favicon.ico") }}"&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
  &lt;div class="container"&gt;
      &lt;div class="col"&gt;
  
          &lt;h2&gt;Output form&lt;/h2&gt;
          &lt;br&gt;
          &lt;div class="form-group" &gt;
              &lt;form&gt;
  
              &lt;h3&gt;Output 1&lt;/h3&gt;
              &lt;P&gt;Your name is = {{name}}&lt;/p&gt;
  
              &lt;h3&gt;Output 2&lt;/h3&gt;
              &lt;P&gt;Your age is = {{age}} &lt;/p&gt;
  
              &lt;h3&gt;Output 3&lt;/h3&gt;
              &lt;P&gt;Your number is = {{number}}&lt;/p&gt;
  
              &lt;h3&gt;Output 4&lt;/h3&gt;
              &lt;P&gt;Your feeling is = {{feeling}} &lt;/p&gt;
  
  
              &lt;/form&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I cant understand why it works with only 2. When I comment out the following it works fine:</p>
  
  <pre><code>@app.route('/input/', methods=["GET","POST"])
  def input():
      name=request.form['name']
      age=request.form['age']
      #number=request.form['number']
      #feeling=request.form['feeling']
  
      return render_template('output.html', name = name, age = age) #number = number, feeling = feeling)
  </code></pre>
  
  <p>It's probably something quite obvious but I just can't see it. </p>
  
  <p>Thanks for the help!</p>