title: Print result to webpage via Flask (Python)
body: <p>I hope someone can give me a hand with this. I'm trying to print the output of a calculation result onto a webpage and it's just not showing - I really don't understand how the exact same function is working perfectly for another result, but not anything else.</p>
  <pre><code>from flask import Flask, render_template
  
  app = Flask(__name__)
  
  stackList = []
  latestNumber = 0
  
  
  @app.route('/')
  @app.route('/calc/')
  @app.route('/calc/peek')
  def calcPeek():
      return render_template('peek.html', stackList=stackList)
  
  @app.route('/calc/push/&lt;number&gt;')
  def pushNumber(number):
      stackList.append(number)
      latestNumber = number
      print(stackList)
      return render_template('push.html', number=number, latestNumber=latestNumber)
  
  @app.route('/calc/pop')
  def calcPop():
      stackList.pop()
      return render_template('pop.html', stackList=stackList)
  
  @app.route('/calc/add')
  def calcAdd():
      numOne = stackList[-1]
      numTwo = stackList[-2]
      addResult = int(numOne) + int(numTwo)
      stackList.pop()
      stackList.pop()
      stackList.append(addResult) 
      print(addResult)
      return render_template('add.html', stackList=stackList, addResult=addResult)
  
  @app.route('/calc/subtract')
  def calcSubtract():
      numOne = stackList[-1]
      numTwo = stackList[-2]
      minusResult = int(numOne) - int(numTwo)
      stackList.pop()
      stackList.pop()
      stackList.append(minusResult) 
      print(minusResult)
      return render_template('add.html', stackList=stackList, minusResult=minusResult)
  </code></pre>
  <p>And here's the add.html file.</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;title&gt;Add&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;Result: {{addResult}} &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The peek, push/number and add functions all work fine and give me the result I need. However, if I try the same function with divide/multiply/subtract it doesn't actually show anything on the webpage - No error or anything. The result prints to the console but doesn't generate any output for the webpage. Subtract.html below</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
      &lt;title&gt;Subtract&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt; {{minusResult}} &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Is there anything I'm missing thats completely obvious here? Thanks for any help with this in advance</p>