Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -147,6 +147,82 @@ current_time_and_date = get_current_time_and_date()
|
|
147 |
# else:
|
148 |
# return "<p>Failed to fetch local events</p>"
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
def fetch_local_events():
|
151 |
api_key = os.environ['SERP_API']
|
152 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
|
@@ -160,53 +236,18 @@ def fetch_local_events():
|
|
160 |
.event-item {
|
161 |
font-family: 'Verdana', sans-serif;
|
162 |
color: #333;
|
163 |
-
background-color: #f0f8ff;
|
164 |
margin-bottom: 15px;
|
165 |
padding: 10px;
|
166 |
-
border-radius: 5px;
|
167 |
-
transition: box-shadow 0.3s ease, background-color 0.3s ease;
|
168 |
font-weight: bold;
|
169 |
}
|
170 |
-
.event-item:hover {
|
171 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
172 |
-
background-color: #e6f7ff;
|
173 |
-
}
|
174 |
.event-item a {
|
175 |
color: #1E90FF;
|
176 |
text-decoration: none;
|
177 |
-
font-weight: bold;
|
178 |
}
|
179 |
.event-item a:hover {
|
180 |
text-decoration: underline;
|
181 |
}
|
182 |
-
.event-preview {
|
183 |
-
position: absolute;
|
184 |
-
display: none;
|
185 |
-
border: 1px solid #ccc;
|
186 |
-
border-radius: 5px;
|
187 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
188 |
-
background-color: white;
|
189 |
-
z-index: 1000;
|
190 |
-
max-width: 300px;
|
191 |
-
padding: 10px;
|
192 |
-
font-family: 'Verdana', sans-serif;
|
193 |
-
color: #333;
|
194 |
-
}
|
195 |
</style>
|
196 |
-
<script>
|
197 |
-
function showPreview(event, previewContent) {
|
198 |
-
var previewBox = document.getElementById('event-preview');
|
199 |
-
previewBox.innerHTML = previewContent;
|
200 |
-
previewBox.style.left = event.pageX + 'px';
|
201 |
-
previewBox.style.top = event.pageY + 'px';
|
202 |
-
previewBox.style.display = 'block';
|
203 |
-
}
|
204 |
-
function hidePreview() {
|
205 |
-
var previewBox = document.getElementById('event-preview');
|
206 |
-
previewBox.style.display = 'none';
|
207 |
-
}
|
208 |
-
</script>
|
209 |
-
<div id="event-preview" class="event-preview"></div>
|
210 |
"""
|
211 |
for index, event in enumerate(events_results):
|
212 |
title = event.get("title", "No title")
|
@@ -214,7 +255,7 @@ def fetch_local_events():
|
|
214 |
location = event.get("address", "No location")
|
215 |
link = event.get("link", "#")
|
216 |
events_html += f"""
|
217 |
-
<div class="event-item"
|
218 |
<a href='{link}' target='_blank'>{index + 1}. {title}</a>
|
219 |
<p>Date: {date}<br>Location: {location}</p>
|
220 |
</div>
|
|
|
147 |
# else:
|
148 |
# return "<p>Failed to fetch local events</p>"
|
149 |
|
150 |
+
# def fetch_local_events():
|
151 |
+
# api_key = os.environ['SERP_API']
|
152 |
+
# url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
|
153 |
+
|
154 |
+
# response = requests.get(url)
|
155 |
+
# if response.status_code == 200:
|
156 |
+
# events_results = response.json().get("events_results", [])
|
157 |
+
# events_html = """
|
158 |
+
# <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
|
159 |
+
# <style>
|
160 |
+
# .event-item {
|
161 |
+
# font-family: 'Verdana', sans-serif;
|
162 |
+
# color: #333;
|
163 |
+
# background-color: #f0f8ff;
|
164 |
+
# margin-bottom: 15px;
|
165 |
+
# padding: 10px;
|
166 |
+
# border-radius: 5px;
|
167 |
+
# transition: box-shadow 0.3s ease, background-color 0.3s ease;
|
168 |
+
# font-weight: bold;
|
169 |
+
# }
|
170 |
+
# .event-item:hover {
|
171 |
+
# box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
172 |
+
# background-color: #e6f7ff;
|
173 |
+
# }
|
174 |
+
# .event-item a {
|
175 |
+
# color: #1E90FF;
|
176 |
+
# text-decoration: none;
|
177 |
+
# font-weight: bold;
|
178 |
+
# }
|
179 |
+
# .event-item a:hover {
|
180 |
+
# text-decoration: underline;
|
181 |
+
# }
|
182 |
+
# .event-preview {
|
183 |
+
# position: absolute;
|
184 |
+
# display: none;
|
185 |
+
# border: 1px solid #ccc;
|
186 |
+
# border-radius: 5px;
|
187 |
+
# box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
188 |
+
# background-color: white;
|
189 |
+
# z-index: 1000;
|
190 |
+
# max-width: 300px;
|
191 |
+
# padding: 10px;
|
192 |
+
# font-family: 'Verdana', sans-serif;
|
193 |
+
# color: #333;
|
194 |
+
# }
|
195 |
+
# </style>
|
196 |
+
# <script>
|
197 |
+
# function showPreview(event, previewContent) {
|
198 |
+
# var previewBox = document.getElementById('event-preview');
|
199 |
+
# previewBox.innerHTML = previewContent;
|
200 |
+
# previewBox.style.left = event.pageX + 'px';
|
201 |
+
# previewBox.style.top = event.pageY + 'px';
|
202 |
+
# previewBox.style.display = 'block';
|
203 |
+
# }
|
204 |
+
# function hidePreview() {
|
205 |
+
# var previewBox = document.getElementById('event-preview');
|
206 |
+
# previewBox.style.display = 'none';
|
207 |
+
# }
|
208 |
+
# </script>
|
209 |
+
# <div id="event-preview" class="event-preview"></div>
|
210 |
+
# """
|
211 |
+
# for index, event in enumerate(events_results):
|
212 |
+
# title = event.get("title", "No title")
|
213 |
+
# date = event.get("date", "No date")
|
214 |
+
# location = event.get("address", "No location")
|
215 |
+
# link = event.get("link", "#")
|
216 |
+
# events_html += f"""
|
217 |
+
# <div class="event-item" onmouseover="showPreview(event, 'Date: {date}<br>Location: {location}')" onmouseout="hidePreview()">
|
218 |
+
# <a href='{link}' target='_blank'>{index + 1}. {title}</a>
|
219 |
+
# <p>Date: {date}<br>Location: {location}</p>
|
220 |
+
# </div>
|
221 |
+
# """
|
222 |
+
# return events_html
|
223 |
+
# else:
|
224 |
+
# return "<p>Failed to fetch local events</p>"
|
225 |
+
|
226 |
def fetch_local_events():
|
227 |
api_key = os.environ['SERP_API']
|
228 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
|
|
|
236 |
.event-item {
|
237 |
font-family: 'Verdana', sans-serif;
|
238 |
color: #333;
|
|
|
239 |
margin-bottom: 15px;
|
240 |
padding: 10px;
|
|
|
|
|
241 |
font-weight: bold;
|
242 |
}
|
|
|
|
|
|
|
|
|
243 |
.event-item a {
|
244 |
color: #1E90FF;
|
245 |
text-decoration: none;
|
|
|
246 |
}
|
247 |
.event-item a:hover {
|
248 |
text-decoration: underline;
|
249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
"""
|
252 |
for index, event in enumerate(events_results):
|
253 |
title = event.get("title", "No title")
|
|
|
255 |
location = event.get("address", "No location")
|
256 |
link = event.get("link", "#")
|
257 |
events_html += f"""
|
258 |
+
<div class="event-item">
|
259 |
<a href='{link}' target='_blank'>{index + 1}. {title}</a>
|
260 |
<p>Date: {date}<br>Location: {location}</p>
|
261 |
</div>
|