-
Notifications
You must be signed in to change notification settings - Fork 5
/
sandbox.html
84 lines (75 loc) · 2.48 KB
/
sandbox.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>
Parking Reservation API SandBox
</title>
<script type="text/javascript">
// JS function to hit the API with Json data
function submit_json(data, target){
var request = new XMLHttpRequest();
request.withCredentials = true;
request.open("POST", target, true);
request.send(data);
request.onreadystatechange = function (got) {
if (request.readyState == request.DONE) {
var response = request.responseText;
document.getElementById("response").innerHTML = response;
}
}
};
// JS function to create Json of registeration data
function register(){
var uname = document.getElementById("regname").value;
var pswd = document.getElementById("reg_password").value;
var email = document.getElementById("reg_email").value;
var targt = "http://127.0.0.1:8000/users/register";
var dt = {username:uname, password:pswd, email:email};
var dat = JSON.stringify(dt);
submit_json(dat, targt);
};
// JS function to create Json of Login data
function login(){
var uname = document.getElementById("login_username").value;
var pswd = document.getElementById("login_password").value;
var targt = "http://127.0.0.1:8000/users/login";
var dt = {username:uname, password:pswd};
var dat = JSON.stringify(dt);
submit_json(dat, targt);
}
</script>
</head>
<body>
<center>
<h1>
Parking Reservation APIs.
</h1><br>
<h3>Note:- This template assumes API server running at http://127.0.0.1:8000 </h3>
</center><br><br>
<!-- Reflect the API response here -->
<hr>
RESPONSE:-
<b><div id="response"></div></b>
<br><hr><br><br>
<!-- User Registration API -->
<h3>1. User registration API</h3>
Endpoint:- /users/register <br>
Method = POST <br>
Fields:- <br>
Username <input type="test" id="regname"> <br>
Password <input type="password" id="reg_password"> <br>
Email <input type="email" id="reg_email"> <br>
<button type="submit" onclick="register()"> Submit </button>
<br><br>
<!-- User login API -->
<h3>2. User login API</h3>
Endpoint:- /users/login <br>
Method = POST <br>
Fields:- <br>
Username <input type="test" id="login_username"> <br>
Password <input type="password" id="login_password"> <br>
<button type="submit" onclick="login()"> Submit </button>
<br><br>
</body>
</html>