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 and see the output in the command line.</p>
  
  <p>What do I need to do in the function?</p>
  
  <p>What do I need to do in the template?</p>
  
  <p>EDIT:</p>
  
  <p>I am trying to use Markus Unterwaditzer's code with a template.</p>
  
  <pre><code>{% extends "base.html" %}
  {% block content %}
  
  {% autoescape false %}
  
  {{word}}
  
  {% endautoescape %}
  
  {% endblock %}
  </code></pre>
  
  <p>Python code</p>
  
  <pre><code>import flask
  from flask import render_template
  import subprocess
  import time
  
  app = flask.Flask(__name__)
  
  @app.route('/yield')
  def index():
      def inner():
          for x in range(1000):
              yield '%s&lt;br/&gt;\n' % x
              time.sleep(1)
      return render_template('simple.html', word=inner())
      #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=8080)
  </code></pre>
  
  <p>And it runs but I don't see anything in the browser.</p>