Flask App Update Pre Tag With The Contents Of Dynamic Server Log File
Using a logfile that is produced by a long computation and refresh it into a pre tag. Scripted with a JS function (not inline) that can be toggled on or off, instead of always on.
Solution 1:
You need to rewrite the setInterval callback function and add an xhr.onload callback like this:
//global JavaScript Variables here
var timerId;
/*Fetches*/
function refreshPre(url, blRefresh = true) {
if (blRefresh) {
//declare and assign setInterval
timerId = window.setInterval(function(){ populatePre(url) },1000);
} else {
//stop setInterval
window.clearInterval(timerId);
timerId = null;
}
}
function populatePre(url) {
var output = document.getElementById('contents');
var xhr = new XMLHttpRequest();
// Listen to xhr events for response:
xhr.onload = function(){
output.innerText = xhr.response;
}
xhr.open('GET', url);
xhr.send();
}
Post a Comment for "Flask App Update Pre Tag With The Contents Of Dynamic Server Log File"