Swathi6 commited on
Commit
a66d611
·
verified ·
1 Parent(s): 051b72a

Create templates/dashboard.html

Browse files
Files changed (1) hide show
  1. templates/dashboard.html +33 -0
templates/dashboard.html ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Dashboard</title>
7
+ <script>
8
+ let inactivityTimer;
9
+ function resetTimer() {
10
+ clearTimeout(inactivityTimer);
11
+ inactivityTimer = setTimeout(logout, 5 * 60 * 1000); // 5 minutes
12
+ }
13
+ function logout() {
14
+ fetch('/logout', { method: 'GET' }) // Call Flask logout route
15
+ .then(response => {
16
+ window.location.href = "/logout"; // Redirect to login page
17
+ })
18
+ .catch(error => console.error("Logout failed", error));
19
+ }
20
+ // Listen for user activity and reset the timer
21
+ document.addEventListener("mousemove", resetTimer);
22
+ document.addEventListener("keydown", resetTimer);
23
+ document.addEventListener("click", resetTimer);
24
+ document.addEventListener("touchstart", resetTimer);
25
+ // Start the inactivity timer on page load
26
+ resetTimer();
27
+ </script>
28
+ </head>
29
+ <body>
30
+ <h1>Welcome to the Dashboard</h1>
31
+ <p>You will be logged out automatically after 5 minutes of inactivity.</p>
32
+ </body>
33
+ </html>