Files
Alarm/dev/index.html
T
2026-10-18 22:31:16 +01:00

78 lines
2.5 KiB
HTML

<!-- Copyright (C) 2026 Dcntrlized
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Dev</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<script>
function handleFormSubmit(event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const data = Object.fromEntries(formData.entries());
fetch(form.action, {
method: form.method,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => {
console.log("Success: " + JSON.stringify(data));
})
.catch((error) => {
console.error("Error:", error);
});
}
</script>
<form
id="login"
action="http://127.0.0.1:8080/auth/login"
method="post"
onsubmit="handleFormSubmit(event)"
>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
<br />
<label for="password">Password:</label>
<input type="password" id="password" name="password" required />
<br />
<button type="submit">Login</button>
</form>
<form
id="register"
action="http://127.0.0.1:8080/auth/register"
method="post"
onsubmit="handleFormSubmit(event)"
>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required />
<br />
<label for="password">Password:</label>
<input type="password" id="password" name="password" required />
<br />
<button type="submit">Register</button>
</form>
</body>
</html>