vishurdx commited on
Commit
16cc416
·
verified ·
1 Parent(s): 2297b37

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +132 -0
index.html ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>LA Festival Guide AI</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ .typing-dot {
10
+ animation: typing 1.4s infinite ease-in-out both;
11
+ }
12
+ .typing-dot:nth-child(1) { animation-delay: -0.32s; }
13
+ .typing-dot:nth-child(2) { animation-delay: -0.16s; }
14
+ @keyframes typing {
15
+ 0%, 80%, 100% { transform: scale(0); }
16
+ 40% { transform: scale(1); }
17
+ }
18
+ </style>
19
+ </head>
20
+ <body class="bg-gray-100 h-screen flex flex-col items-center justify-center p-4">
21
+
22
+ <!-- Main Card -->
23
+ <div class="w-full max-w-2xl bg-white rounded-2xl shadow-xl overflow-hidden flex flex-col h-[80vh]">
24
+
25
+ <!-- Header -->
26
+ <div class="bg-gradient-to-r from-blue-600 to-purple-600 p-6 text-white">
27
+ <h1 class="text-2xl font-bold">🌴 LA Festival Guide</h1>
28
+ <p class="text-blue-100 text-sm">Ask about events, dates, and festivals in LA</p>
29
+ </div>
30
+
31
+ <!-- Chat Area -->
32
+ <div id="chat-box" class="flex-1 overflow-y-auto p-6 space-y-4 bg-gray-50">
33
+ <!-- Bot Welcome Message -->
34
+ <div class="flex items-start">
35
+ <div class="bg-blue-100 p-3 rounded-lg rounded-tl-none max-w-[80%] text-gray-800">
36
+ Hello! I'm your LA events concierge. What are you looking for today?
37
+ </div>
38
+ </div>
39
+ </div>
40
+
41
+ <!-- Input Area -->
42
+ <div class="p-4 bg-white border-t border-gray-200">
43
+ <form id="chat-form" class="flex gap-2">
44
+ <input type="text" id="user-input"
45
+ class="flex-1 px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
46
+ placeholder="e.g., Music festivals in August..." autocomplete="off">
47
+ <button type="submit"
48
+ class="bg-blue-600 text-white px-6 py-3 rounded-lg font-semibold hover:bg-blue-700 transition-colors">
49
+ Send
50
+ </button>
51
+ </form>
52
+ </div>
53
+ </div>
54
+
55
+ <script>
56
+ const chatBox = document.getElementById('chat-box');
57
+ const chatForm = document.getElementById('chat-form');
58
+ const userInput = document.getElementById('user-input');
59
+
60
+ function appendMessage(text, isUser) {
61
+ const div = document.createElement('div');
62
+ div.className = `flex ${isUser ? 'justify-end' : 'items-start'}`;
63
+
64
+ const bubble = document.createElement('div');
65
+ bubble.className = isUser
66
+ ? 'bg-blue-600 text-white p-3 rounded-lg rounded-tr-none max-w-[80%]'
67
+ : 'bg-white border border-gray-200 p-3 rounded-lg rounded-tl-none max-w-[80%] text-gray-800 shadow-sm';
68
+
69
+ // Allow basic markdown-like formatting for bot
70
+ bubble.innerHTML = isUser ? text : text.replace(/\n/g, '<br>');
71
+
72
+ div.appendChild(bubble);
73
+ chatBox.appendChild(div);
74
+ chatBox.scrollTop = chatBox.scrollHeight;
75
+ }
76
+
77
+ function showTyping() {
78
+ const div = document.createElement('div');
79
+ div.id = 'typing-indicator';
80
+ div.className = 'flex items-start';
81
+ div.innerHTML = `
82
+ <div class="bg-gray-200 p-3 rounded-lg rounded-tl-none flex space-x-1">
83
+ <div class="w-2 h-2 bg-gray-500 rounded-full typing-dot"></div>
84
+ <div class="w-2 h-2 bg-gray-500 rounded-full typing-dot"></div>
85
+ <div class="w-2 h-2 bg-gray-500 rounded-full typing-dot"></div>
86
+ </div>
87
+ `;
88
+ chatBox.appendChild(div);
89
+ chatBox.scrollTop = chatBox.scrollHeight;
90
+ }
91
+
92
+ function removeTyping() {
93
+ const el = document.getElementById('typing-indicator');
94
+ if (el) el.remove();
95
+ }
96
+
97
+ chatForm.addEventListener('submit', async (e) => {
98
+ e.preventDefault();
99
+ const message = userInput.value.trim();
100
+ if (!message) return;
101
+
102
+ // 1. Show User Message
103
+ appendMessage(message, true);
104
+ userInput.value = '';
105
+ showTyping();
106
+
107
+ try {
108
+ // 2. Call Python Backend
109
+ const response = await fetch('/api/chat', {
110
+ method: 'POST',
111
+ headers: { 'Content-Type': 'application/json' },
112
+ body: JSON.stringify({ message: message })
113
+ });
114
+
115
+ const data = await response.json();
116
+
117
+ // 3. Show Bot Response
118
+ removeTyping();
119
+ if (response.ok) {
120
+ appendMessage(data.response, false);
121
+ } else {
122
+ appendMessage("⚠️ Error: " + (data.detail || "Failed to fetch"), false);
123
+ }
124
+ } catch (err) {
125
+ removeTyping();
126
+ appendMessage("⚠️ Network error. Please try again.", false);
127
+ console.error(err);
128
+ }
129
+ });
130
+ </script>
131
+ </body>
132
+ </html>