-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
73 lines (62 loc) · 2.42 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
function sendQuery() {
axios.post(
"https://mk1.diva.so:4242/handleQueryDemo",
{'query': document.getElementById('query').value},
{ headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
"Authorization": `Bearer ${document.getElementById('secret').value}`
}}
).then((response) => {
console.log(response.data);
var br = document.createElement("br");
var element = document.getElementById("res");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
for (var i = 0; i < response.data.res.length; i++){
var tit = document.createElement("h3");
var tittext = document.createTextNode(response.data.res[i]['title'])
var tag = document.createElement("p");
var text = document.createTextNode(response.data.res[i]['text']);
tit.appendChild(tittext);
tag.appendChild(text);
element.appendChild(br);
element.appendChild(tit);
element.appendChild(tag);
}
})
.catch((error => {console.log(error);}))
};
</script>
</head>
<body>
<section id="main">
<h2 style="text-align: center;">Find your stuff:</h2>
<center>
<label for="query">Query: </label>
<input type="text" id="query" name="query" placeholder="query">
<label for="query">Secret: </label>
<input type="text" id="secret" name="secret" placeholder="secret">
<button id="submitbutt"> Search me</button>
</div>
</center>
<div id="res">
</section>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
console.log()
document.getElementById("submitbutt").addEventListener("click", sendQuery);
});
</script>
<!--<section id="sponsors"></section>-->
</body>
</html>