Skip to content

Commit 1a5d6bd

Browse files
author
MarvinJWendt
committed
Created the debuger
1 parent 0b177bc commit 1a5d6bd

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

debug.html

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1+
<html>
12

3+
<head>
4+
<title>API Debugger</title>
5+
<style>
6+
7+
.center {
8+
text-align: center;
9+
margin-left: auto;
10+
margin-right: auto;
11+
margin-top: 100px;
12+
}
13+
14+
textarea {
15+
width: 600px;
16+
height: 450px;
17+
font-size: 18px;
18+
}
19+
20+
input {
21+
height: 30px;
22+
width: 1200px;
23+
font-size: 15px;
24+
}
25+
26+
button {
27+
font-size: 20px;
28+
margin-top: 10px;
29+
}
30+
31+
</style>
32+
</head>
33+
34+
<body>
35+
<div class="center">
36+
37+
<h1>API-Debugger</h1>
38+
39+
<div>
40+
<input id="url" placeholder="/api" />
41+
<br><br>
42+
</div>
43+
44+
<div>
45+
<textarea id="body" placeholder="Body"></textarea>
46+
<textarea id="response" placeholder="Response"></textarea>
47+
</div>
48+
49+
<div>
50+
<button onclick="submit('GET')">GET</button>
51+
<button onclick="submit('POST')">POST</button>
52+
<button onclick="submit('PUT')">PUT</button>
53+
<button onclick="submit('DELETE')">DELETE</button>
54+
</div>
55+
56+
<div>
57+
<button onclick="toJSON()">Beauty-JSON</button>
58+
</div>
59+
60+
</div>
61+
</body>
62+
63+
</html>
64+
65+
<script>
66+
67+
function submit(method)
68+
{
69+
70+
var http = new XMLHttpRequest();
71+
http.open(method, document.getElementById('url').value, true);
72+
73+
http.onreadystatechange = function() {
74+
if(http.readyState == 4)
75+
{
76+
if(http.status == 200 | http.status == 201 | http.status == 202)
77+
{
78+
document.getElementById('response').value = http.responseText;
79+
}
80+
else
81+
{
82+
document.getElementById('response').value = "Error: " + http.status
83+
}
84+
}
85+
}
86+
87+
http.send(document.getElementById('body').value);
88+
}
89+
90+
function toJSON()
91+
{
92+
document.getElementById('response').value = JSON.stringify(JSON.parse(document.getElementById('response').value), null, '\t');
93+
}
94+
95+
</script>

0 commit comments

Comments
 (0)