feat: web frontend with Alpine.js
This commit is contained in:
+29
-1
@@ -1,2 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html><head><title>Login</title></head><body><h1>Login</h1></body></html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>yDropbox Login</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>yDropbox</h1>
|
||||
<form id="loginForm">
|
||||
<input type="password" id="token" placeholder="Access Token" required>
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const token = document.getElementById('token').value;
|
||||
const res = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({token})
|
||||
});
|
||||
if (res.ok) window.location.href = '/';
|
||||
else alert('Invalid token');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user