login-template/web/index.html

52 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>login test</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/login/css/style.css" rel="stylesheet">
</head>
<body>
hiii
<form action="/login" method="post" class="login-form" id="login-form">
<div class="form-test">
<label for="name">Enter your username: </label>
<input type="text" name="username" id="name" required />
</div>
<div class="form-test">
<label for="pass">Enter your password: </label>
<input type="text" name="password" id="password" required />
</div>
<div class="form-test">
<input type="submit" value="Log in" />
</div>
</form>
<button id="logout-button">Log Out</button>
</body>
<script defer>
console.log("FUCK YEAH JAVASCRIPT TIME BABYYYYYYY");
document.getElementById("login-form").addEventListener("submit", async (event) => {
event.preventDefault();
const username = event.target.username.value;
const password = event.target.password.value;
const token = await fetch("/login", {
method: "POST",
header: {"Content-Type": "application/json"},
body: JSON.stringify({username, password})
})
console.log(await token.text());
});
document.getElementById("logout-button").addEventListener("click", async (event) => {
event.preventDefault();
const loggedout = await fetch("/logout", {
method: "POST"
});
console.log(await loggedout.text());
});
</script>
</html>