ISSUE: I have an output (from popen) that I need to stream/display line by line on a flask served page. PA is serving the full content all at once, that's not what I want. I'm aiming to have row by row displayed as what is happening on my local flask server testing. I've also tried this on an open file/log I've been reading too (not just the popen)
GOAL: I want to "emit" lines from either popen or log file read to the flask served webpage (as they are happening, some minor delay is ok)
MY ATTEMPT: I've been looking deep into PA Buffering article to solve my issue (since everything is on NGINX servers and there's load balancing happening) -- its not fixing my issue...Here's what I've tried this:
return Response(inner(), mimetype='text/html', headers={'X-Accel-Buffering': 'no'})
NOTES:
-
All strings end with a
\n
on the yield statements -
The
inner()
function is kicking off the whole popen stuff too -- it works (I even did asleep.time(1)
for each yielded line) but it's not happy/working for me
ASK: Is there something else I should be doing here to get it to work properly? I'm totally lost here -- can someone please copy/paste a sample of code that would work?
Much appreciated!
-Doug Jr.