mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
26 lines
662 B
TypeScript
26 lines
662 B
TypeScript
export function keepGUIAlive() {
|
|
async function getRequest(url = '') {
|
|
const response = await fetch(url, {
|
|
method: 'GET',
|
|
cache: 'no-cache',
|
|
});
|
|
return response;
|
|
}
|
|
|
|
const keepAliveServer = () => {
|
|
const url = document.location;
|
|
const route = '/flaskwebgui-keep-server-alive';
|
|
getRequest(url + route).then((data) => {
|
|
return data;
|
|
});
|
|
};
|
|
|
|
if (!import.meta.env.NODE_ENV || import.meta.env.NODE_ENV === 'production') {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const intervalRequest = 3 * 1000;
|
|
keepAliveServer();
|
|
setInterval(keepAliveServer, intervalRequest);
|
|
});
|
|
}
|
|
}
|