jithenderchoudary commited on
Commit
4276167
·
verified ·
1 Parent(s): 191db0a

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +51 -0
templates/index.html ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>FAQ Chatbot</title>
7
+ <style>
8
+ /* Basic styles for the chatbot */
9
+ #chatbot {
10
+ width: 300px;
11
+ border: 1px solid #ddd;
12
+ padding: 10px;
13
+ margin: 20px;
14
+ }
15
+ #chatbox {
16
+ height: 300px;
17
+ overflow-y: auto;
18
+ margin-bottom: 10px;
19
+ }
20
+ #user_input {
21
+ width: 100%;
22
+ padding: 10px;
23
+ }
24
+ </style>
25
+ </head>
26
+ <body>
27
+ <div id="chatbot">
28
+ <div id="chatbox"></div>
29
+ <input type="text" id="user_input" placeholder="Ask a question..." />
30
+ <button onclick="sendQuestion()">Send</button>
31
+ </div>
32
+
33
+ <script>
34
+ function sendQuestion() {
35
+ const question = document.getElementById("user_input").value;
36
+
37
+ fetch('http://localhost:5000/ask', {
38
+ method: 'POST',
39
+ headers: { 'Content-Type': 'application/json' },
40
+ body: JSON.stringify({ 'question': question })
41
+ })
42
+ .then(response => response.json())
43
+ .then(data => {
44
+ const chatbox = document.getElementById("chatbox");
45
+ chatbox.innerHTML += "<div>User: " + question + "</div>";
46
+ chatbox.innerHTML += "<div>Bot: " + data.answer + "</div>";
47
+ });
48
+ }
49
+ </script>
50
+ </body>
51
+ </html>