Spaces:
Sleeping
Sleeping
| <html> | |
| <head> | |
| <title>Google OAuth Demo</title> | |
| </head> | |
| <body> | |
| <h1>Google Login Demo</h1> | |
| <div id="welcome-message">Checking login...</div> | |
| <button onclick="loginWithGoogle()">Login with Google</button> | |
| <script> | |
| async function checkLogin() { | |
| try { | |
| const res = await fetch("/api/user"); | |
| if (res.ok) { | |
| const user = await res.json(); | |
| document.getElementById("welcome-message").innerText = | |
| `Welcome, ${user.name} (${user.email})`; | |
| } else { | |
| document.getElementById("welcome-message").innerText = | |
| "You are not logged in."; | |
| } | |
| } catch (err) { | |
| console.error("Error checking login:", err); | |
| } | |
| } | |
| function loginWithGoogle() { | |
| window.location.href = "/google/login"; | |
| } | |
| checkLogin(); | |
| </script> | |
| </body> | |
| </html> | |