Repository navigation
Expand file tree
/
Copy pathform.html
More file actions
68 lines (58 loc) · 1.66 KB
/
Copy pathform.html
File metadata and controls
68 lines (58 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<title>Login And Title Page</title>
<link rel="stylesheet" href="form.css">
</head>
<body>
<h2>Sign-Up</h2>
<input id="sign-username" placeholder="Username">
<br><br>
<input id="sign-password" type="password" placeholder="Password">
<br><br>
<button onclick="signup()">Sign Up</button>
<h2>Login</h2>
<input id="login-username" placeholder="Username">
<br><br>
<input id="login-password" type="password" placeholder="Password">
<br><br>
<button onclick="login()">Submit</button>
<p id="result"></p>
<script>
function login() {
fetch("http://127.0.0.1:8000/login", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username: document.getElementById("login-username").value,
password: document.getElementById("login-password").value
})
})
.then(res => res.json())
.then(data => {
document.getElementById("result").innerText = data.message;
})
.catch(err => console.error(err));
}
function signup() {
fetch("http://127.0.0.1:8000/signup", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username: document.getElementById("sign-username").value,
password: document.getElementById("sign-password").value
})
})
.then(res => res.json())
.then(data => {
document.getElementById("result").innerText = data.message;
})
.catch(err => console.error(err));
}
</script>
</body>
</html>