title: How to continuously display Python output in a Webpage?
body: <p>I want to be able to visit a webpage and it will run a python function and display the progress in the webpage.</p>
  
  <p>So when you visit the webpage you can see the output of the script as if you ran it from the command line.</p>
  
  <p>Based on the answer here</p>
  
  <p><a href="https://stackoverflow.com/questions/15041620/how-to-continuously-display-python-output-in-a-webpage">How to continuously display python output in a webpage?</a></p>
  
  <p>I am trying to display output from <strong>PYTHON</strong></p>
  
  <p>I am trying to use Markus Unterwaditzer's code with a python function.</p>
  
  <pre><code>import flask
  import subprocess
  
  app = flask.Flask(__name__)
  
  def test():
      print "Test"
  
  @app.route('/yield')
  def index():
      def inner():
          proc = subprocess.Popen(
              test(),
              shell=True,
              stdout=subprocess.PIPE
          )
  
          while proc.poll() is None:
              yield proc.stdout.readline() + '&lt;br/&gt;\n'
      return flask.Response(inner(), mimetype='text/html')  # text/html is required for most browsers to show the partial page immediately
  
  app.run(debug=True, port=5005)
  </code></pre>
  
  <p>And it runs but I don't see anything in the browser.</p>