Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +187 -23
templates/index.html
CHANGED
@@ -3,25 +3,183 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
<style>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
.
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</style>
|
26 |
</head>
|
27 |
<body>
|
@@ -56,8 +214,10 @@
|
|
56 |
<!-- Chatbot Interface -->
|
57 |
<div class="chat-container">
|
58 |
<h2>Ask the Financial Chatbot</h2>
|
59 |
-
<
|
60 |
-
|
|
|
|
|
61 |
<div id="chat-response"></div>
|
62 |
</div>
|
63 |
</div>
|
@@ -66,21 +226,25 @@
|
|
66 |
function sendChat() {
|
67 |
const input = document.getElementById('chat-input').value;
|
68 |
if (!input || input.length < 3) {
|
69 |
-
document.getElementById('chat-response').innerHTML = '<p style="color:
|
70 |
return;
|
71 |
}
|
72 |
|
|
|
73 |
fetch('/chat', {
|
74 |
method: 'POST',
|
75 |
headers: { 'Content-Type': 'application/json' },
|
76 |
body: JSON.stringify({ message: input })
|
77 |
})
|
78 |
-
.then(response =>
|
|
|
|
|
|
|
79 |
.then(data => {
|
80 |
document.getElementById('chat-response').innerHTML = `<p><strong>Response:</strong> ${data.response}</p><p><strong>Category:</strong> ${data.category}</p>`;
|
81 |
})
|
82 |
.catch(error => {
|
83 |
-
document.getElementById('chat-response').innerHTML = '<p style="color:
|
84 |
console.error('Chat error:', error);
|
85 |
});
|
86 |
}
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Financial News & Chatbot</title>
|
7 |
<style>
|
8 |
+
/* Global Styles */
|
9 |
+
* {
|
10 |
+
margin: 0;
|
11 |
+
padding: 0;
|
12 |
+
box-sizing: border-box;
|
13 |
+
}
|
14 |
+
body {
|
15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
16 |
+
background: linear-gradient(135deg, #f4f7fa 0%, #e8ecef 100%);
|
17 |
+
color: #333;
|
18 |
+
line-height: 1.6;
|
19 |
+
padding: 20px;
|
20 |
+
}
|
21 |
+
.news-container {
|
22 |
+
max-width: 900px;
|
23 |
+
margin: 0 auto;
|
24 |
+
background: #fff;
|
25 |
+
border-radius: 10px;
|
26 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
27 |
+
padding: 20px;
|
28 |
+
overflow: hidden;
|
29 |
+
}
|
30 |
+
h1 {
|
31 |
+
color: #1a3c6d;
|
32 |
+
font-size: 2em;
|
33 |
+
margin-bottom: 15px;
|
34 |
+
text-align: center;
|
35 |
+
text-transform: uppercase;
|
36 |
+
letter-spacing: 1px;
|
37 |
+
}
|
38 |
+
.last-updated {
|
39 |
+
color: #666;
|
40 |
+
font-size: 0.9em;
|
41 |
+
text-align: center;
|
42 |
+
margin-bottom: 20px;
|
43 |
+
font-style: italic;
|
44 |
+
}
|
45 |
+
|
46 |
+
/* Categories */
|
47 |
+
.categories {
|
48 |
+
display: flex;
|
49 |
+
flex-wrap: wrap;
|
50 |
+
justify-content: center;
|
51 |
+
gap: 10px;
|
52 |
+
margin-bottom: 25px;
|
53 |
+
}
|
54 |
+
.categories a {
|
55 |
+
color: #007bff;
|
56 |
+
text-decoration: none;
|
57 |
+
padding: 8px 15px;
|
58 |
+
background: #e6f0ff;
|
59 |
+
border-radius: 20px;
|
60 |
+
transition: background 0.3s, color 0.3s;
|
61 |
+
}
|
62 |
+
.categories a:hover {
|
63 |
+
background: #007bff;
|
64 |
+
color: #fff;
|
65 |
+
}
|
66 |
+
|
67 |
+
/* News Items */
|
68 |
+
.news-item {
|
69 |
+
background: #fafafa;
|
70 |
+
padding: 15px;
|
71 |
+
margin-bottom: 15px;
|
72 |
+
border-radius: 8px;
|
73 |
+
border-left: 4px solid #1a3c6d;
|
74 |
+
transition: transform 0.2s, box-shadow 0.2s;
|
75 |
+
}
|
76 |
+
.news-item:hover {
|
77 |
+
transform: translateY(-2px);
|
78 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
|
79 |
+
}
|
80 |
+
.news-item h2 {
|
81 |
+
font-size: 1.2em;
|
82 |
+
margin-bottom: 8px;
|
83 |
+
}
|
84 |
+
.news-item a {
|
85 |
+
color: #1a3c6d;
|
86 |
+
text-decoration: none;
|
87 |
+
font-weight: 600;
|
88 |
+
}
|
89 |
+
.news-item a:hover {
|
90 |
+
color: #007bff;
|
91 |
+
}
|
92 |
+
.news-item p {
|
93 |
+
color: #555;
|
94 |
+
font-size: 0.95em;
|
95 |
+
margin-bottom: 8px;
|
96 |
+
}
|
97 |
+
.meta {
|
98 |
+
color: #888;
|
99 |
+
font-size: 0.85em;
|
100 |
+
}
|
101 |
+
.error {
|
102 |
+
color: #d32f2f;
|
103 |
+
text-align: center;
|
104 |
+
font-weight: bold;
|
105 |
+
}
|
106 |
+
|
107 |
+
/* Chatbot Section */
|
108 |
+
.chat-container {
|
109 |
+
margin-top: 30px;
|
110 |
+
padding: 20px;
|
111 |
+
background: #1a3c6d;
|
112 |
+
color: #fff;
|
113 |
+
border-radius: 10px;
|
114 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
115 |
+
}
|
116 |
+
.chat-container h2 {
|
117 |
+
font-size: 1.5em;
|
118 |
+
margin-bottom: 15px;
|
119 |
+
color: #fff;
|
120 |
+
text-align: center;
|
121 |
+
}
|
122 |
+
.chat-input {
|
123 |
+
width: 70%;
|
124 |
+
padding: 10px;
|
125 |
+
border: none;
|
126 |
+
border-radius: 20px 0 0 20px;
|
127 |
+
font-size: 1em;
|
128 |
+
outline: none;
|
129 |
+
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
|
130 |
+
}
|
131 |
+
.chat-button {
|
132 |
+
padding: 10px 20px;
|
133 |
+
border: none;
|
134 |
+
border-radius: 0 20px 20px 0;
|
135 |
+
background: #007bff;
|
136 |
+
color: #fff;
|
137 |
+
font-size: 1em;
|
138 |
+
cursor: pointer;
|
139 |
+
transition: background 0.3s;
|
140 |
+
}
|
141 |
+
.chat-button:hover {
|
142 |
+
background: #0056b3;
|
143 |
+
}
|
144 |
+
.chat-form {
|
145 |
+
display: flex;
|
146 |
+
justify-content: center;
|
147 |
+
gap: 0;
|
148 |
+
margin-bottom: 15px;
|
149 |
+
}
|
150 |
+
#chat-response {
|
151 |
+
margin-top: 15px;
|
152 |
+
padding: 10px;
|
153 |
+
background: rgba(255, 255, 255, 0.1);
|
154 |
+
border-radius: 8px;
|
155 |
+
font-size: 0.95em;
|
156 |
+
line-height: 1.5;
|
157 |
+
}
|
158 |
+
#chat-response p {
|
159 |
+
margin: 5px 0;
|
160 |
+
}
|
161 |
+
#chat-response strong {
|
162 |
+
color: #e6f0ff;
|
163 |
+
}
|
164 |
+
|
165 |
+
/* Responsive Design */
|
166 |
+
@media (max-width: 600px) {
|
167 |
+
.news-container {
|
168 |
+
padding: 15px;
|
169 |
+
}
|
170 |
+
h1 {
|
171 |
+
font-size: 1.5em;
|
172 |
+
}
|
173 |
+
.news-item h2 {
|
174 |
+
font-size: 1em;
|
175 |
+
}
|
176 |
+
.chat-input {
|
177 |
+
width: 60%;
|
178 |
+
}
|
179 |
+
.chat-button {
|
180 |
+
padding: 10px 15px;
|
181 |
+
}
|
182 |
+
}
|
183 |
</style>
|
184 |
</head>
|
185 |
<body>
|
|
|
214 |
<!-- Chatbot Interface -->
|
215 |
<div class="chat-container">
|
216 |
<h2>Ask the Financial Chatbot</h2>
|
217 |
+
<div class="chat-form">
|
218 |
+
<input type="text" id="chat-input" class="chat-input" placeholder="e.g., What's today’s Nifty trend?">
|
219 |
+
<button onclick="sendChat()" class="chat-button">Send</button>
|
220 |
+
</div>
|
221 |
<div id="chat-response"></div>
|
222 |
</div>
|
223 |
</div>
|
|
|
226 |
function sendChat() {
|
227 |
const input = document.getElementById('chat-input').value;
|
228 |
if (!input || input.length < 3) {
|
229 |
+
document.getElementById('chat-response').innerHTML = '<p style="color: #ff9999;">Please enter a valid question (minimum 3 characters).</p>';
|
230 |
return;
|
231 |
}
|
232 |
|
233 |
+
document.getElementById('chat-response').innerHTML = '<p>Loading...</p>';
|
234 |
fetch('/chat', {
|
235 |
method: 'POST',
|
236 |
headers: { 'Content-Type': 'application/json' },
|
237 |
body: JSON.stringify({ message: input })
|
238 |
})
|
239 |
+
.then(response => {
|
240 |
+
if (!response.ok) throw new Error('Network response was not ok');
|
241 |
+
return response.json();
|
242 |
+
})
|
243 |
.then(data => {
|
244 |
document.getElementById('chat-response').innerHTML = `<p><strong>Response:</strong> ${data.response}</p><p><strong>Category:</strong> ${data.category}</p>`;
|
245 |
})
|
246 |
.catch(error => {
|
247 |
+
document.getElementById('chat-response').innerHTML = '<p style="color: #ff9999;">Error: Could not get a response from the chatbot.</p>';
|
248 |
console.error('Chat error:', error);
|
249 |
});
|
250 |
}
|