Alimubariz124 commited on
Commit
aacf656
·
verified ·
1 Parent(s): a8508e0

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +78 -19
index.html CHANGED
@@ -1,19 +1,78 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>