Initial commit
This commit is contained in:
commit
9fe412be11
58 changed files with 6215 additions and 0 deletions
66
templates/index.html
Normal file
66
templates/index.html
Normal file
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Registration</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<h1>Create new user</h1>
|
||||
<form action="/register" method="post" id="signup">
|
||||
<h1>Sign Up</h1>
|
||||
<div class="field">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" id="name" name="name" placeholder="Enter your profile name" />
|
||||
<small></small>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="email">PubKey:</label>
|
||||
<input type="text" id="pubkey" name="pubkey" placeholder="Enter your pubkey" />
|
||||
<small></small>
|
||||
</div>
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
const form = document.getElementById('signup');
|
||||
|
||||
form.addEventListener('submit', async (event) => {
|
||||
// stop form submission
|
||||
event.preventDefault();
|
||||
|
||||
const name = form.elements['name'];
|
||||
const pubkey = form.elements['pubkey'];
|
||||
|
||||
// getting the element's value
|
||||
let userName = name.value;
|
||||
let pubKey = pubkey.value;
|
||||
|
||||
console.log(`${userName}:${pubKey}`);
|
||||
const data = { name: userName, pubkey: pubKey};
|
||||
|
||||
// Send user data
|
||||
await postJSON(data);
|
||||
});
|
||||
|
||||
async function postJSON(data) {
|
||||
try {
|
||||
const response = await fetch("http://localhost:8085/register", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
console.log("Success:", result);
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue