init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>CoRE.Vision — Вход</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body class="login-body">
|
||||
<form class="login-card" id="login-form">
|
||||
<div class="brand login-brand">CoRE<span>.Vision</span></div>
|
||||
<input type="text" id="username" placeholder="Логин" autocomplete="username" autofocus>
|
||||
<input type="password" id="password" placeholder="Пароль" autocomplete="current-password">
|
||||
<button type="submit">Войти</button>
|
||||
<div class="login-err" id="login-err"></div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
const form = document.getElementById("login-form");
|
||||
const err = document.getElementById("login-err");
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
err.textContent = "";
|
||||
const r = await fetch("/api/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
username: document.getElementById("username").value,
|
||||
password: document.getElementById("password").value,
|
||||
}),
|
||||
});
|
||||
if (r.ok) {
|
||||
location.href = "/";
|
||||
} else {
|
||||
const d = await r.json().catch(() => ({}));
|
||||
err.textContent = d.detail || "Ошибка входа";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user