Python Flask: Looping through requests and outputting to webpage live
<p>I want to write a program in Flask that prints out the status codes of websites asynchronously to a webpage with a time delay, i.e.,</p>

<pre><code>import flask
import time
import requests
app = flask.Flask(__name__)

@app.route('/yield')
     def index():
          def inner():
              for x in range(100):
                  time.sleep(1)
                  req = requests.get('https://www.youtube.com/watch?v=[somenumber]')
                  print(req.status_code)
                  return '&lt;br/&gt;\n' + str(req.status_code)

          return flask.Response(inner(), mimetype='text/html')



app.run()
</code></pre>

<p>The output of this on the webpage is just <a href="https://i.stack.imgur.com/hhCL8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hhCL8.png" alt="enter image description here"></a></p>

<p>when I expected it to be 99 '404' messages due to the for loop's range.</p>