title: Streaming data with Python and Flask
body: <p>I can't seem to figure out how to using Flask's streaming. Here's my code:</p>
  
  <pre><code>@app.route('/scans/')
  def scans_query():
      url_for('static', filename='.*')
      def generate():
          yield render_template('scans.html')
          for i in xrange(50):
              sleep(.5)
              yield render_template('scans.html', **locals())
      return Response(stream_with_context(generate()))
  </code></pre>
  
  <p>and in my template:</p>
  
  <pre><code>&lt;p&gt;{% i %}&lt;/p&gt;
  </code></pre>
  
  <p>I would like to see a counter on the page that changes every half second. Instead, the closest I've gotten is the page printing out each number on the next line.</p>