title: How to import numbers from html into Python using Flask, perform operations on them in python and return them to html
body: <p>I would like to know the general format for importing a resultant number from html and converting it to two decimal places using Flask. I currently have some code, but it's not entirely functional. I would like to know some of the basics regarding importing HTML using flask and then editing a resultant number from a calculation to two decimal places. For example, if I enter 1 into a converting calculator for Liters and I would like to get back the number of quarts to two decimal places, how would I achieve this? Thank you for your time and patience.</p>
  
  <p>The objective of this exercise is to use only flask to intake a value from html, round the value, and return this rounded value to html. Example:</p>
  
  <p>I've calculated the conversion rate in html of liters to pints, quarts, and gallons. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form name = "LiterConverter"&gt;
  
           &lt;p align="left"&gt;
  
               INPUT(Liters)&lt;br&gt;
  
               A &lt;input name="LiterDisplay"&gt;
  
               &lt;input type="button" value="Convert" onclick=" quartform.quartsdisplay.value=eval(1.057 * LiterConverter.LiterDisplay.value)"&gt;&lt;br&gt;
  
           &lt;div style="display:flex; justify-content:flex-end; width:17%; padding:0;"&gt;&lt;input type="button" value="Clear" onclick="LiterConverter.LiterDisplay.value='';quartform.quartsdisplay.value=''"&gt;&lt;/div&gt;
  
           &lt;/p&gt;
  
       &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is where I enter the information. I would like to take this information into python, round it, and export it back to the html. </p>
  
  <p>This is how I'm attempting to import the information now in python using flask now:</p>
  
  <pre><code>def process_input(s):
  
      return eval(s)
  
  
  
  app = Flask(__name__, template_folder='template')
  
  
  
  @app.route('/')
  
  def index():
  
      return render_template('converter.html')
  
  
  
  @app.route('/', methods=['POST'])
  
  def volume_numbers():
  
      Quarts = process_input(request.form.get('quartform'))
  
      newQuarts = round(Quarts, 2)
  
      return render_template('converter.html', Volume_in_Quarts = newQuarts)
  </code></pre>
  
  <p>Now, How I have attempted to insert the information back into html is the following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form name="quartform"&gt;
  
          &lt;p align="left"&gt;
  
             C &lt;input name="quartsdisplay" &lt;p&gt;{{ Volume_in_Quarts}&lt;/p&gt;&gt; Volume in Quarts
  
          &lt;/p&gt;
  
      &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>However when I run this in python through flask I still get that the volume is some integer, say 21 followed by more than two decimals. Like the following: 21.2312341234. I only want 21.23, but I still get the previous output even though I have supposed filtered these results through flask and sent them back to html. This situation is perplexing, and I'm wondering if it's some kind of formatting issue or if I'm just missing something simple. I thank you for your time and patience in answering this question.</p>