Server/templates/login.html

47 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Авторизация учителя</title>
<style>
body { font-family: Arial, sans-serif; padding: 40px; }
form {
max-width: 300px;
margin: 0 auto;
}
input, button {
width: 100%;
padding: 10px;
margin: 10px 0;
}
</style>
</head>
<body>
<form onsubmit="login(event)">
<h2>Вход для учителя</h2>
<input type="password" id="password" placeholder="Пароль" required>
<button type="submit">Войти</button>
<p id="error" style="color: red;"></p>
</form>
<script>
async function login(event) {
event.preventDefault();
const password = document.getElementById('password').value;
const response = await fetch('/teacher/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ password })
});
if (response.ok) {
window.location.href = '/teacher';
} else {
document.getElementById('error').textContent = 'Неверный пароль';
}
}
</script>
</body>
</html>