I'm trying stream stdout of a function to a webpage. The some_function.main takes few mins to complete and I want to show the stdout to the screen (its using logger).
This code does execute the function but I don't get anything on the webpage, I see everything on the screen when I run "python app.py" (I'm using Flask)
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader
@app.route('/buildvm', methods=['GET', 'POST'])
def buildvm():
   if 'username' not in session:
      return redirect(url_for('login'))
   if request.method == "POST" and 'username' in session:
      parmsdic = {'key':'val'}
        def inner(disc):
          sys.path.append('/some/path')
          import some_fuction
          #for x in range(100):
          for x in some_fuction.main(disc, quite=True):
             yield '{0}<br/>\n'.format(x)
       env = Environment(loader=FileSystemLoader('templates'))
       tmpl = env.get_template('results.html')
       return Response(tmpl.generate(result=inner(parmsdic)))
   return render_template('index.html')
my results.html looks like:
{% block body %}
<body>
  {% for line in result %}
    {{ line }}
  {% endfor %}
</body>
{% endblock %}
Any help would be much appreciated, Thank you in advance.
 
     
    