title: Display data streamed from a Flask view as it updates
body: <p>I have a view that generates data and streams it in real time.  I can't figure out how to send this data to a variable that I can use in my HTML template.  My current solution just outputs the data to a blank page as it arrives, which works, but I want to include it in a larger page with formatting.  How do I update, format, and display the data as it is streamed to the page?</p>
  
  <pre><code>import flask
  import time, math
  
  app = flask.Flask(__name__)
  
  @app.route('/')
  def index():
      def inner():
          # simulate a long process to watch
          for i in range(500):
              j = math.sqrt(i)
              time.sleep(1)
              # this value should be inserted into an HTML template
              yield str(i) + '&lt;br/&gt;\n'
      return flask.Response(inner(), mimetype='text/html')
  
  app.run(debug=True)
  </code></pre>