97 lines
2.8 KiB
HTML
97 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
background-color: #f1f1f1;
|
|
}
|
|
.container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background-color: white;
|
|
padding: 40px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
.container img {
|
|
max-height: 150px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.container form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
width: 100%;
|
|
max-width: 300px;
|
|
}
|
|
.container form label {
|
|
margin-bottom: 8px;
|
|
font-weight: bold;
|
|
}
|
|
.container form input {
|
|
padding: 10px;
|
|
margin-bottom: 20px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 16px;
|
|
}
|
|
.container form button {
|
|
padding: 10px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
background-color: #007BFF;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<img src="VitLogo.png" alt="Logo">
|
|
<form id="loginForm">
|
|
<label for="username">Username:</label>
|
|
<input type="text" id="username" required>
|
|
<label for="password">Password:</label>
|
|
<input type="password" id="password" required>
|
|
<button type="submit">Login</button>
|
|
</form>
|
|
</div>
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
const response = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ username, password })
|
|
});
|
|
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
console.log('Received token:', data.token);
|
|
localStorage.setItem('token', data.token);
|
|
window.location.href = '/dashboard.html';
|
|
} else {
|
|
alert('Login failed');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|