Spaces:
Running
Running
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Dashboard</title> | |
<script> | |
let inactivityTimer; | |
function resetTimer() { | |
clearTimeout(inactivityTimer); | |
inactivityTimer = setTimeout(logout, 5 * 60 * 1000); // 5 minutes | |
} | |
function logout() { | |
fetch('/logout', { method: 'GET' }) // Call Flask logout route | |
.then(response => { | |
window.location.href = "/logout"; // Redirect to login page | |
}) | |
.catch(error => console.error("Logout failed", error)); | |
} | |
// Listen for user activity and reset the timer | |
document.addEventListener("mousemove", resetTimer); | |
document.addEventListener("keydown", resetTimer); | |
document.addEventListener("click", resetTimer); | |
document.addEventListener("touchstart", resetTimer); | |
// Start the inactivity timer on page load | |
resetTimer(); | |
</script> | |
</head> | |
<body> | |
<h1>Welcome to the Dashboard</h1> | |
<p>You will be logged out automatically after 5 minutes of inactivity.</p> | |
</body> | |
</html> | |