tonyassi commited on
Commit
520e2df
·
verified ·
1 Parent(s): 2369ccf

Upload templates_index.html

Browse files
Files changed (1) hide show
  1. templates/templates_index.html +306 -0
templates/templates_index.html ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, maximum-scale=1">
6
+ <title>Flask Chat App</title>
7
+ <style>
8
+ body, html {
9
+ margin: 0;
10
+ padding: 0;
11
+ width: 100%;
12
+ height: 100%;
13
+ background-color: #fddde6;
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: center;
17
+ justify-content: flex-start;
18
+ font-family: Arial, sans-serif;
19
+ font-weight: 300;
20
+ }
21
+ #video-container {
22
+ padding-top: 2%;
23
+ width: auto;
24
+ height: auto;
25
+ }
26
+ #video-container video {
27
+ width: auto;
28
+ height: 35vh;
29
+ }
30
+
31
+ #chat-container, #input-container {
32
+ width: 90%;
33
+ max-width: 1200px;
34
+ margin: 10px;
35
+ }
36
+ #chat-container {
37
+ flex: 1;
38
+ overflow-y: auto;
39
+ background-color: white;
40
+ border-radius: 10px;
41
+ padding: 2%;
42
+ box-shadow: 0 0 10px rgba(0,0,0,0.1);
43
+ display: flex;
44
+ flex-direction: column;
45
+ }
46
+ .chat-bubble {
47
+ margin: 5px;
48
+ padding: 10px;
49
+ border-radius: 10px;
50
+ max-width: 80%;
51
+ }
52
+ .user-bubble {
53
+ align-self: flex-end;
54
+ background-color: #e0e0e0;
55
+ }
56
+ .bot-bubble {
57
+ align-self: flex-start;
58
+ background-color: #ffb6c1;
59
+ color: white;
60
+ }
61
+ #input-container {
62
+ display: flex;
63
+ align-items: center;
64
+ padding-bottom: 2%;
65
+ }
66
+ #input-container input {
67
+ flex: 1;
68
+ padding: 10px;
69
+ border: 1px solid #ccc;
70
+ border-radius: 5px;
71
+ height: 2.5vh;
72
+ }
73
+
74
+ #input-container button {
75
+ padding: 0;
76
+ margin-left: 10px;
77
+ border: none;
78
+ background-color: transparent;
79
+ cursor: pointer;
80
+ height: calc(2.5vh + 15px);
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ }
85
+
86
+ #input-container button img {
87
+ height: 100%;
88
+ width: auto;
89
+ }
90
+
91
+ /* New styles for the menu */
92
+ .menu {
93
+ position: absolute;
94
+ top: 10px;
95
+ left: 10px;
96
+ z-index: 1000;
97
+ }
98
+
99
+ .menu .hamburger {
100
+ display: block;
101
+ cursor: pointer;
102
+ width: 30px;
103
+ height: 30px;
104
+ }
105
+
106
+ .menu .hamburger div {
107
+ width: 100%;
108
+ height: 4px;
109
+ background-color: black;
110
+ margin: 5px 0;
111
+ transition: all 0.3s;
112
+ }
113
+
114
+ .menu-content {
115
+ display: none;
116
+ position: absolute;
117
+ top: 40px;
118
+ left: 0;
119
+ background-color: white;
120
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
121
+ border-radius: 5px;
122
+ overflow: hidden;
123
+ width: 150px;
124
+ }
125
+
126
+ .menu-content a {
127
+ display: block;
128
+ padding: 5px 10px;
129
+ color: black;
130
+ text-decoration: none;
131
+ transition: background-color 0.3s;
132
+ }
133
+
134
+ .menu-content a:hover {
135
+ background-color: #f0f0f0;
136
+ }
137
+
138
+ #audio-recording-container {
139
+ display: none;
140
+ align-items: center;
141
+ justify-content: center;
142
+ width: 90%;
143
+ max-width: 1200px;
144
+ margin: 10px;
145
+ padding-top: 7%;
146
+ }
147
+
148
+ #audio-record-button {
149
+ width: 150px;
150
+ height: 150px;
151
+ background-color: #e1fceb;
152
+ color: black;
153
+ border-radius: 50%;
154
+ cursor: pointer;
155
+ display: flex;
156
+ align-items: center;
157
+ justify-content: center;
158
+ font-size: 16px;
159
+ font-weight: bold;
160
+ border: 5px solid white;
161
+ box-shadow: 0 0 20px 5px rgba(255, 255, 255, 0.8);
162
+
163
+ }
164
+ #audio-record-button.recording {
165
+ background-color: #f44336;
166
+ box-shadow: 0 0 20px 10px rgba(255, 255, 255, 1);
167
+ }
168
+ </style>
169
+ </head>
170
+ <body>
171
+ <div class="menu">
172
+ <div class="hamburger" onclick="toggleMenu()">
173
+ <div></div>
174
+ <div></div>
175
+ <div></div>
176
+ </div>
177
+ <div class="menu-content" id="menu-content">
178
+ <a href="#" onclick="showTextChat()">Text Chat</a>
179
+ <a href="#" onclick="showAudioChat()">Audio Chat</a>
180
+ <a href="#">Settings</a>
181
+ </div>
182
+ </div>
183
+
184
+ <div id="video-container">
185
+ <video src="https://cdn-lfs-us-1.huggingface.co/repos/61/c4/61c4367976a0aef9d7ba3bb5650c0efc98207f17f6d3a4a71d3d7f9b265578a3/159ba43daee671b34e01d65c7b753bac22c139f653eeeaf3c6da1220b7c9ecf0?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27lucy-vid-1.mp4%3B+filename%3D%22lucy-vid-1.mp4%22%3B&response-content-type=video%2Fmp4&Expires=1723399367&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcyMzM5OTM2N319LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzYxL2M0LzYxYzQzNjc5NzZhMGFlZjlkN2JhM2JiNTY1MGMwZWZjOTgyMDdmMTdmNmQzYTRhNzFkM2Q3ZjliMjY1NTc4YTMvMTU5YmE0M2RhZWU2NzFiMzRlMDFkNjVjN2I3NTNiYWMyMmMxMzlmNjUzZWVlYWYzYzZkYTEyMjBiN2M5ZWNmMD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSomcmVzcG9uc2UtY29udGVudC10eXBlPSoifV19&Signature=PqaCnSHH9xJ%7E-TgkrZ0mH96bbPf7IJBnJWZHYqNU4hFKRa0N9ibxdFm5HAWySMOCNrVGMVTzGjTWAX8gmcQNfHtDRL%7EfX%7El8zZpP2tErEm4Q8AmjhmYTWDATBG0pXCJQtaSjesQK3q9RQ2yMEiJDC9VWa2OhiBJW25LnL%7EAqPLiNpX8sRs07boI677XDmgRL7qOWEOtrBqvJn5ZCgaLybRhu8ySKvCSUwWtEv1gWQ-XT28NZ6h4nDy5yEqkMw9yVcJs4U8JUCHL2cxgHxGK22FK1o3EMiZ3LvMjzWZNVlLUbJJVFO4XDNqMsumV6oLEmWNZtILyEaD6FfGw6grLJNw__&Key-Pair-Id=K24J24Z295AEI9" playsinline autoplay loop muted></video>
186
+ </div>
187
+ <div id="chat-container"></div>
188
+ <div id="input-container">
189
+ <input type="text" id="user-input" placeholder="Type your message...">
190
+ <button onclick="sendMessage()">
191
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/648a824a8ca6cf9857d1349c/aJO71FyXi40-U_AOjwPmt.png" alt="Send">
192
+ </button>
193
+ </div>
194
+
195
+ <div id="audio-recording-container">
196
+ <button id="audio-record-button">START</button>
197
+ </div>
198
+
199
+ <script>
200
+ function sendMessage() {
201
+ var userInput = document.getElementById('user-input').value;
202
+ if (userInput.trim() === "") return;
203
+
204
+ var chatContainer = document.getElementById('chat-container');
205
+
206
+ // Create user bubble
207
+ var userBubble = document.createElement('div');
208
+ userBubble.textContent = userInput;
209
+ userBubble.className = 'chat-bubble user-bubble';
210
+ chatContainer.appendChild(userBubble);
211
+
212
+ // Create bot bubble with "..." text
213
+ var botBubble = document.createElement('div');
214
+ botBubble.textContent = ". . .";
215
+ botBubble.className = 'chat-bubble bot-bubble';
216
+ chatContainer.appendChild(botBubble);
217
+
218
+ chatContainer.scrollTop = chatContainer.scrollHeight;
219
+ document.getElementById('user-input').value = '';
220
+
221
+ var xhr = new XMLHttpRequest();
222
+ xhr.open('POST', '/send_message', true);
223
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
224
+ xhr.onload = function () {
225
+ if (xhr.status === 200) {
226
+ var response = JSON.parse(xhr.responseText);
227
+
228
+ // Update bot bubble with the actual response
229
+ botBubble.textContent = response.response;
230
+ chatContainer.scrollTop = chatContainer.scrollHeight;
231
+ }
232
+ };
233
+ xhr.send('user_input=' + encodeURIComponent(userInput));
234
+ }
235
+
236
+
237
+ document.getElementById('user-input').addEventListener('keydown', function(event) {
238
+ if (event.key === 'Enter') {
239
+ sendMessage();
240
+ }
241
+ });
242
+
243
+ function toggleMenu() {
244
+ var menuContent = document.getElementById('menu-content');
245
+ if (menuContent.style.display === 'block') {
246
+ menuContent.style.display = 'none';
247
+ } else {
248
+ menuContent.style.display = 'block';
249
+ }
250
+ }
251
+
252
+ function showTextChat() {
253
+ document.getElementById('chat-container').style.display = 'flex';
254
+ document.getElementById('input-container').style.display = 'flex';
255
+ document.getElementById('audio-recording-container').style.display = 'none';
256
+ document.getElementById('menu-content').style.display = 'none';
257
+ }
258
+
259
+ function showAudioChat() {
260
+ document.getElementById('chat-container').style.display = 'none';
261
+ document.getElementById('input-container').style.display = 'none';
262
+ document.getElementById('audio-recording-container').style.display = 'flex';
263
+ document.getElementById('menu-content').style.display = 'none';
264
+ }
265
+
266
+ let mediaRecorder;
267
+ let audioChunks = [];
268
+ const recordButton = document.getElementById('audio-record-button');
269
+ let isRecording = false;
270
+ recordButton.addEventListener('click', () => {
271
+ if (isRecording) {
272
+ mediaRecorder.stop();
273
+ recordButton.textContent = 'START';
274
+ recordButton.classList.remove('recording');
275
+ } else {
276
+ navigator.mediaDevices.getUserMedia({ audio: true })
277
+ .then(stream => {
278
+ mediaRecorder = new MediaRecorder(stream);
279
+ mediaRecorder.start();
280
+ mediaRecorder.addEventListener('dataavailable', event => {
281
+ audioChunks.push(event.data);
282
+ });
283
+ mediaRecorder.addEventListener('stop', () => {
284
+ const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
285
+ const formData = new FormData();
286
+ formData.append('file', audioBlob, 'audio.wav');
287
+ fetch('/upload', {
288
+ method: 'POST',
289
+ body: formData
290
+ })
291
+ .then(response => response.json())
292
+ .catch(error => {
293
+ console.error('Error:', error);
294
+ });
295
+ audioChunks = [];
296
+ });
297
+ recordButton.textContent = 'STOP';
298
+ recordButton.classList.add('recording');
299
+ });
300
+ }
301
+ isRecording = !isRecording;
302
+ });
303
+
304
+ </script>
305
+ </body>
306
+ </html>