Spaces:
Running
Running
Upload index.html
Browse files- index.html +78 -19
index.html
CHANGED
@@ -1,19 +1,78 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Landon Hotel Chatbot</title>
|
5 |
+
<style>
|
6 |
+
/* CSS styles for the chatbot interface */
|
7 |
+
#chat-container {
|
8 |
+
width: 400px;
|
9 |
+
height: 500px;
|
10 |
+
border: 1px solid #ccc;
|
11 |
+
overflow-y: scroll;
|
12 |
+
padding: 10px;
|
13 |
+
}
|
14 |
+
|
15 |
+
.message {
|
16 |
+
margin-bottom: 10px;
|
17 |
+
}
|
18 |
+
|
19 |
+
.user {
|
20 |
+
font-weight: bold;
|
21 |
+
color: blue;
|
22 |
+
}
|
23 |
+
|
24 |
+
.bot {
|
25 |
+
font-weight: bold;
|
26 |
+
color: green;
|
27 |
+
}
|
28 |
+
</style>
|
29 |
+
</head>
|
30 |
+
<body>
|
31 |
+
<h1>Landon Hotel Chatbot</h1>
|
32 |
+
<div id="chat-container"></div>
|
33 |
+
<input type="text" id="user-input" placeholder="Type your message..." />
|
34 |
+
<button id="send-btn">Send</button>
|
35 |
+
<script>
|
36 |
+
const chatContainer = document.getElementById('chat-container');
|
37 |
+
const userInput = document.getElementById('user-input');
|
38 |
+
const sendBtn = document.getElementById('send-btn');
|
39 |
+
|
40 |
+
sendBtn.addEventListener('click', sendMessage);
|
41 |
+
|
42 |
+
function sendMessage() {
|
43 |
+
const userMessage = userInput.value.trim();
|
44 |
+
if (userMessage) {
|
45 |
+
displayMessage('user', userMessage);
|
46 |
+
sendMessageToServer(userMessage);
|
47 |
+
userInput.value = '';
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
function displayMessage(sender, message) {
|
52 |
+
const messageElement = document.createElement('div');
|
53 |
+
messageElement.classList.add('message');
|
54 |
+
messageElement.classList.add(sender);
|
55 |
+
messageElement.textContent = `${sender}: ${message}`;
|
56 |
+
chatContainer.appendChild(messageElement);
|
57 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
58 |
+
}
|
59 |
+
|
60 |
+
function sendMessageToServer(message) {
|
61 |
+
fetch('/chatbot', {
|
62 |
+
method: 'POST',
|
63 |
+
headers: {
|
64 |
+
'Content-Type': 'application/json',
|
65 |
+
},
|
66 |
+
body: JSON.stringify({ question: message }),
|
67 |
+
})
|
68 |
+
.then((response) => response.json())
|
69 |
+
.then((data) => {
|
70 |
+
displayMessage('bot', data.response);
|
71 |
+
})
|
72 |
+
.catch((error) => {
|
73 |
+
console.error('Error:', error);
|
74 |
+
});
|
75 |
+
}
|
76 |
+
</script>
|
77 |
+
</body>
|
78 |
+
</html>
|