Spaces:
Runtime error
Runtime error
Create index.html
Browse files- index.html +98 -0
index.html
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Hugging Face Chat UI</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
background: linear-gradient(to bottom, #111, #333);
|
11 |
+
margin: 0;
|
12 |
+
padding: 0;
|
13 |
+
box-sizing: border-box;
|
14 |
+
display: flex;
|
15 |
+
justify-content: center;
|
16 |
+
align-items: center;
|
17 |
+
height: 100vh;
|
18 |
+
}
|
19 |
+
|
20 |
+
.chat-container {
|
21 |
+
background: #6B7280;
|
22 |
+
color: #FFD21E;
|
23 |
+
width: 400px;
|
24 |
+
padding: 20px;
|
25 |
+
border-radius: 8px;
|
26 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
27 |
+
}
|
28 |
+
|
29 |
+
.chat-container input {
|
30 |
+
width: calc(100% - 70px);
|
31 |
+
padding: 10px;
|
32 |
+
border: 1px solid #FFD21E;
|
33 |
+
border-radius: 20px 0 0 20px;
|
34 |
+
}
|
35 |
+
|
36 |
+
.chat-container button {
|
37 |
+
width: 70px;
|
38 |
+
padding: 10px;
|
39 |
+
border: none;
|
40 |
+
background: #FF9D00;
|
41 |
+
color: #111;
|
42 |
+
border-radius: 0 20px 20px 0;
|
43 |
+
cursor: pointer;
|
44 |
+
}
|
45 |
+
|
46 |
+
.chat-message {
|
47 |
+
margin: 10px 0;
|
48 |
+
padding: 10px;
|
49 |
+
border-radius: 8px;
|
50 |
+
}
|
51 |
+
|
52 |
+
.user-message {
|
53 |
+
background: #FFD21E;
|
54 |
+
color: #111;
|
55 |
+
text-align: right;
|
56 |
+
}
|
57 |
+
|
58 |
+
.ai-message {
|
59 |
+
background: #FF9D00;
|
60 |
+
color: #111;
|
61 |
+
text-align: left;
|
62 |
+
}
|
63 |
+
</style>
|
64 |
+
</head>
|
65 |
+
<body>
|
66 |
+
<div class="chat-container">
|
67 |
+
<div id="chat-box"></div>
|
68 |
+
<input type="text" id="user-input" placeholder="Type your message...">
|
69 |
+
<button id="send-button">Send</button>
|
70 |
+
</div>
|
71 |
+
|
72 |
+
<script>
|
73 |
+
const chatBox = document.getElementById('chat-box');
|
74 |
+
const userInput = document.getElementById('user-input');
|
75 |
+
const sendButton = document.getElementById('send-button');
|
76 |
+
|
77 |
+
sendButton.addEventListener('click', () => {
|
78 |
+
// Handle sending user input to the server
|
79 |
+
const message = userInput.value;
|
80 |
+
// Make a POST request to the server to get the AI response
|
81 |
+
fetch('/get_response', {
|
82 |
+
method: 'POST',
|
83 |
+
headers: {
|
84 |
+
'Content-Type': 'application/x-www-form-urlencoded'
|
85 |
+
},
|
86 |
+
body: new URLSearchParams({ user_input: message })
|
87 |
+
})
|
88 |
+
.then(response => response.json())
|
89 |
+
.then(data => {
|
90 |
+
// Display the AI response in the chat box
|
91 |
+
// You can customize the format as per your requirements
|
92 |
+
chatBox.innerHTML += <div class="chat-message user-message">${message}</div>;
|
93 |
+
chatBox.innerHTML += <div class="chat-message ai-message">${data}</div>;
|
94 |
+
});
|
95 |
+
});
|
96 |
+
</script>
|
97 |
+
</body>
|
98 |
+
</html>
|