title: Flask - Simple Calculator App (How to pass a variable to python using a button?)
body: <p>I'm pretty new to python/flask programming and was just wondering on how do I pass a a character to python (Flask)?</p>
  
  <pre><code>&lt;button type="submit" value="1"&gt;1&lt;/button&gt;
  </code></pre>
  
  <p>For example, let's say I have a button 1, which I press. How would I pass the value of the button to python, so I can calculate the value of the expression? I think it should be a POST request but I am unsure.</p>
  
  <p>Also is this the right form for displaying a number after pressing a button?</p>
  
  <pre><code>&lt;output type="textfield" name="answer" value=""/&gt;
  </code></pre>
  
  <p>My main problem is how do I store the expression?</p>
  
  <p>Here is my current routes.py file.</p>
  
  <pre><code>import csv
  import math
  from flask import Flask, redirect, render_template, request, url_for
  from server import app, user_input
  
  @app.route("/", methods=["GET", "POST"])
  def index():
      if request.method == "POST":
          numbers = request.form["numbers"] #numbers is the expression
          str=""
          str+numbers 
          eval(str)
      return render_template("calculator.html")
  </code></pre>