Popen to web page dynamically

I am using the Pyramid web framework to serve a performance model and allow multiple users to use it remotely.

In short, user-supplied parameters are entered into an XML file and then a model written in C ++ and using XML is executed with the subprocess. Opens in a separate view.

The model may take a while and its registration information is important to the user. I was hoping that I could write each line from stdout to an HTML file and then generate an iFrame with that file as the source.

After starting the subprocess, an iFrame is created with the updated HTML file as the source

<iframe id="logSimInlineFrame" src="${request.static_url('fcmod_web:temp/logfile.html')}" Content-Type="text/plain" charset="utf-8"></iframe>

      

I understand that this is not static and I am facing the following error

ValueError: No static URL definition matching fcmod_web:temp/logfile.html

      

So my question is, am I on the right track with an iFrame whose content is Python generated? And if so, how should I provide this data so that it is updated dynamically?

Or, and I suppose it is, is there a more efficient way to stream data from the PSTE stdout to a frame in a web page?

+3


source to share


1 answer


IFrame streaming is cracked as the best. Methods you can use to communicate in real time with the browser



Methods like long polling AJAX and HTTP are not designed for streaming communication. All modern browsers support WebSockets natively - the last browser to not support them is Android 2.2.

For streaming, your regular web server probably won't cut it, so you need to look into for example. uWSGI and Server-Sent support . Note that Python does not have a standard for real-time exchange, unlike WSGI for HTTP, so any solution will be specific to your web server software.

+2


source







All Articles