@ -359,30 +359,32 @@ host.BrowserHost = class {
// informs flaskwebgui to keep server running while gui is running
// as illusrated in https://github.com/ClimenteA/flaskwebgui#install
// and here: https://stackoverflow.com/questions/39993676/code-inside-domcontentloaded-event-not-working
async function getRequest ( url = '' ) {
const response = await fetch ( url , {
method : 'GET' ,
cache : 'no-cache'
} )
return response . json ( )
}
if ( this . document . readyState !== 'loading' ) {
console . log ( 'document is already ready, just execute code here' ) ;
let url = this . document . location
let route = "/flaskwebgui-keep-server-alive"
// let interval_request = 3 * 1000 //sec
let interval _request = 0.5 * 1000 //sec
function keep _alive _server ( ) {
getRequest ( url + route )
. then ( data => { } )
// .then(data => console.log(data))
}
setInterval ( keep _alive _server , interval _request )
}
// ============ to make webgui applications, the following code block shoud be added. ============ //
// async function getRequest(url='') {
// const response = await fetch(url, {
// method: 'GET',
// cache: 'no-cache'
// })
// return response.json()
// }
// if (this.document.readyState !== 'loading') {
// console.log('document is already ready, just execute code here');
// let url = this.document.location
// let route = "/flaskwebgui-keep-server-alive"
// // let interval_request = 3 * 1000 //sec
// let interval_request = 0.5 * 1000 //sec
// function keep_alive_server(){
// getRequest(url + route)
// .then(data => {})
// // .then(data => console.log(data))
// }
// setInterval(keep_alive_server, interval_request)
// }
// ============ to make webgui applications, the above code block shoud be added. ============ //
}