Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -103,9 +103,6 @@ current_time_and_date = get_current_time_and_date()
|
|
103 |
# else:
|
104 |
# return "<p>Failed to fetch local events</p>"
|
105 |
|
106 |
-
import os
|
107 |
-
import requests
|
108 |
-
|
109 |
def fetch_local_events():
|
110 |
api_key = os.environ['SERP_API']
|
111 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
|
@@ -152,7 +149,10 @@ def fetch_local_events():
|
|
152 |
title = event.get("title", "No title")
|
153 |
date_info = event.get("date", {})
|
154 |
date = f"{date_info.get('start_date', '')} {date_info.get('when', '')}".replace("{", "").replace("}", "")
|
155 |
-
location = event.get("address", "No location")
|
|
|
|
|
|
|
156 |
link = event.get("link", "#")
|
157 |
events_html += f"""
|
158 |
<tr>
|
@@ -167,7 +167,6 @@ def fetch_local_events():
|
|
167 |
return "<p>Failed to fetch local events</p>"
|
168 |
|
169 |
|
170 |
-
|
171 |
def fetch_local_weather():
|
172 |
try:
|
173 |
api_key = os.environ['WEATHER_API']
|
|
|
103 |
# else:
|
104 |
# return "<p>Failed to fetch local events</p>"
|
105 |
|
|
|
|
|
|
|
106 |
def fetch_local_events():
|
107 |
api_key = os.environ['SERP_API']
|
108 |
url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Birmingham&hl=en&gl=us&api_key={api_key}'
|
|
|
149 |
title = event.get("title", "No title")
|
150 |
date_info = event.get("date", {})
|
151 |
date = f"{date_info.get('start_date', '')} {date_info.get('when', '')}".replace("{", "").replace("}", "")
|
152 |
+
location = event.get("address", "No location")
|
153 |
+
if isinstance(location, list):
|
154 |
+
location = " ".join(location)
|
155 |
+
location = location.replace("[", "").replace("]", "")
|
156 |
link = event.get("link", "#")
|
157 |
events_html += f"""
|
158 |
<tr>
|
|
|
167 |
return "<p>Failed to fetch local events</p>"
|
168 |
|
169 |
|
|
|
170 |
def fetch_local_weather():
|
171 |
try:
|
172 |
api_key = os.environ['WEATHER_API']
|