-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsingle.html
More file actions
55 lines (53 loc) · 1.33 KB
/
single.html
File metadata and controls
55 lines (53 loc) · 1.33 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
<!DOCTYPE html>
<html>
<head>
<title>OwlAPI interface</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
body, html {
display: grid;
grid-template-rows: auto;
}
span, button, input, pre {
font: 1.2em monospace;
}
input {
width: 25vw;
border: 0;
border-bottom: 1px dashed black;
}
.content {
margin:0 auto;
}
</style>
</head>
<body>
<div id="input" class="content">
<button onclick="submitRequest(this.parentElement)">GET</button>
<span>https://floof.li/fh/single</span>
<input id="data" type="text" value="?dept=CS&course=2A">
</div>
<pre id="output" class="content"></pre>
</body>
<script>
function submitRequest(input) {
var data = input.querySelector('#data');
var output = document.querySelector('#output');
var url = new URL("https://floof.li/fh/single" + data.value);
fetch(url, {
method: 'GET'
})
.then(response => {
return Promise.resolve(response.json());
})
.then(json => {
console.log(json);
output.innerHTML = JSON.stringify(json, null, 2);
})
.catch(err => {
console.log(err);
});
}
</script>
</html>