Swathi6 commited on
Commit
7351004
·
verified ·
1 Parent(s): 8c25f1d

Update template/index.html

Browse files
Files changed (1) hide show
  1. template/index.html +86 -6
template/index.html CHANGED
@@ -4,15 +4,95 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Restaurant Chatbot</title>
7
- <link rel="stylesheet" href="styles.css">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </head>
9
  <body>
10
- <div class="chat-container">
11
- <div class="chat-box" id="chat-box"></div>
12
- <input type="text" id="user-input" class="user-input" placeholder="Type your message..." autofocus>
13
- <button onclick="sendMessage()" class="send-button">Send</button>
 
 
 
14
  </div>
15
 
16
- <script src="script.js"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  </body>
18
  </html>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Restaurant Chatbot</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ }
11
+ #chat-container {
12
+ max-width: 600px;
13
+ margin: 0 auto;
14
+ padding: 20px;
15
+ border: 1px solid #ddd;
16
+ background-color: #f9f9f9;
17
+ }
18
+ #chat-box {
19
+ max-height: 400px;
20
+ overflow-y: auto;
21
+ margin-bottom: 20px;
22
+ border: 1px solid #ddd;
23
+ padding: 10px;
24
+ background-color: #fff;
25
+ }
26
+ #user-input {
27
+ width: 100%;
28
+ padding: 10px;
29
+ margin-top: 10px;
30
+ }
31
+ #send-btn {
32
+ padding: 10px 15px;
33
+ background-color: #007bff;
34
+ color: white;
35
+ border: none;
36
+ cursor: pointer;
37
+ }
38
+ #send-btn:hover {
39
+ background-color: #0056b3;
40
+ }
41
+ .bot-message, .user-message {
42
+ padding: 10px;
43
+ margin-bottom: 10px;
44
+ border-radius: 5px;
45
+ }
46
+ .bot-message {
47
+ background-color: #f1f1f1;
48
+ }
49
+ .user-message {
50
+ background-color: #007bff;
51
+ color: white;
52
+ text-align: right;
53
+ }
54
+ </style>
55
  </head>
56
  <body>
57
+ <div id="chat-container">
58
+ <h2>Restaurant Chatbot</h2>
59
+ <div id="chat-box">
60
+ <!-- Messages will appear here -->
61
+ </div>
62
+ <input type="text" id="user-input" placeholder="Ask about the menu or suggest a dish...">
63
+ <button id="send-btn" onclick="sendMessage()">Send</button>
64
  </div>
65
 
66
+ <script>
67
+ function sendMessage() {
68
+ var userMessage = document.getElementById("user-input").value;
69
+ if (userMessage.trim() === "") return;
70
+
71
+ appendMessage(userMessage, "user");
72
+
73
+ // Send user message to Flask backend
74
+ fetch('/get_response', {
75
+ method: 'POST',
76
+ headers: {
77
+ 'Content-Type': 'application/x-www-form-urlencoded'
78
+ },
79
+ body: 'user_message=' + encodeURIComponent(userMessage)
80
+ })
81
+ .then(response => response.json())
82
+ .then(data => {
83
+ appendMessage(data.response, "bot");
84
+ document.getElementById("user-input").value = "";
85
+ });
86
+ }
87
+
88
+ function appendMessage(message, sender) {
89
+ var chatBox = document.getElementById("chat-box");
90
+ var messageDiv = document.createElement("div");
91
+ messageDiv.classList.add(sender + "-message");
92
+ messageDiv.innerHTML = message;
93
+ chatBox.appendChild(messageDiv);
94
+ chatBox.scrollTop = chatBox.scrollHeight;
95
+ }
96
+ </script>
97
  </body>
98
  </html>