I have a Python application that I launch from a form using mod_wsgi. I would like to display in real time the output of the script, while it is running, to a web page.
Does anybody know how I can do this?
You'll need JavaScript to do this
Possibility 1, data generated by server
- Make a static HTML page with an empty div.
- Place a piece of Javascript code onto it that is run after the page is loaded.
- The JavaScript will contain a timer that downloads the output of your script say every 5 seconds, using AJAX ands sets your div's html to the result.
- The easiest way to get this working is probably to use the AJAX facilities in JQuery.
Possibility 2, data generated by client
- If it is possible to have your dynamic output generated on the client by a piece of JavaScript code this will scale better (since it takes the burden off the server.)
- You may still load the input data needed to compute the dynamic output formatted as JSON by means of AJAX.
Real time output of script on web page using mod_wsgi