Spaces:
Sleeping
Sleeping
Create Templates/index.html
Browse files- Templates/index.html +57 -0
Templates/index.html
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Food Customization Assistant</title>
|
7 |
+
<link rel="stylesheet" href="styles.css">
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<div class="chat-container">
|
11 |
+
<div class="chat-header">
|
12 |
+
<div class="logo">
|
13 |
+
<img src="chef-hat-icon.png" alt="Chef Hat">
|
14 |
+
<h1>Food Customization Assistant</h1>
|
15 |
+
</div>
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<div class="messages" id="messages"></div>
|
19 |
+
|
20 |
+
<div class="input-box">
|
21 |
+
<input id="user-input" type="text" placeholder="Type your message...">
|
22 |
+
<button onclick="sendMessage()">Send</button>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
|
26 |
+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
27 |
+
<script>
|
28 |
+
const messagesDiv = document.getElementById('messages');
|
29 |
+
|
30 |
+
function appendMessage(message, isBot = true) {
|
31 |
+
const div = document.createElement('div');
|
32 |
+
div.classList.add(isBot ? 'bot-message' : 'user-message');
|
33 |
+
div.textContent = message;
|
34 |
+
messagesDiv.appendChild(div);
|
35 |
+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
36 |
+
}
|
37 |
+
|
38 |
+
function sendMessage() {
|
39 |
+
const userMessage = document.getElementById('user-input').value;
|
40 |
+
if (!userMessage) return;
|
41 |
+
|
42 |
+
appendMessage(userMessage, false); // Show user message
|
43 |
+
|
44 |
+
axios.post('http://localhost:5000/chat', { message: userMessage })
|
45 |
+
.then(response => {
|
46 |
+
appendMessage(response.data.bot_message, true); // Show bot response
|
47 |
+
})
|
48 |
+
.catch(error => {
|
49 |
+
console.error('Error:', error);
|
50 |
+
appendMessage('Sorry, I didn’t understand that.', true);
|
51 |
+
});
|
52 |
+
|
53 |
+
document.getElementById('user-input').value = ''; // Clear input field
|
54 |
+
}
|
55 |
+
</script>
|
56 |
+
</body>
|
57 |
+
</html>
|