-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (68 loc) · 1.96 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
<!DOCTYPE html>
<html>
<head>
<title>Question and Answer</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #2c2c2c;
color: #f0f0f0;
margin: 0;
padding: 0;
}
.container {
width: 50%;
margin: 5% auto;
text-align: center;
padding: 20px;
background-color: #3c3c3c;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
input[type="text"] {
width: 80%;
padding: 10px;
margin: 10px 0;
border: none;
border-radius: 4px;
}
input[type="submit"] {
padding: 10px 20px;
cursor: pointer;
background-color: #4caf50;
color: white;
border: none;
border-radius: 4px;
}
.response {
margin-top: 20px;
background-color: #000;
color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<div class="container">
<h1>Ask a Question</h1>
<form id="questionForm">
<input type="text" id="question" name="question" placeholder="Enter your question here">
<input type="submit" value="Submit">
</form>
<div class="response">
<p id="responseText"></p>
</div>
</div>
<script>
document.getElementById('questionForm').onsubmit = async function (e) {
e.preventDefault();
const question = document.getElementById('question').value;
const response = await fetch(`/ask?question=${encodeURIComponent(question)}`);
const data = await response.json();
document.getElementById('responseText').innerText = data.response;
}
</script>
</body>
</html>