I have a python function that calls many services, and prints results of the services called in a log file. this is my code :
def coordinator():
f = file(path,'a')
sys.stdout = f
/* do a lot of stuff */
f.close()
with open(path) as log:
logs = log.read()
return jsonify(log = logs)
The result of the function is returned to a jQuery getJSON function that displays the final log file in a web page :
$.getJSON('/../coordinator',
{//parameters},
function(data) {
//display data.log
}
);
My problem is that the user gets to see the log file only when the execution is finished. Is there a way to display logs as they are written in real time??