Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -103,6 +103,9 @@ current_time_and_date = get_current_time_and_date()
|
|
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}'
|
@@ -141,14 +144,14 @@ def fetch_local_events():
|
|
141 |
<table>
|
142 |
<tr>
|
143 |
<th>Title</th>
|
144 |
-
<th>Date</th>
|
145 |
<th>Location</th>
|
146 |
</tr>
|
147 |
"""
|
148 |
for event in events_results:
|
149 |
title = event.get("title", "No title")
|
150 |
-
date = event.get("date", "No date")
|
151 |
-
location = event.get("address", "No location")
|
152 |
link = event.get("link", "#")
|
153 |
events_html += f"""
|
154 |
<tr>
|
@@ -162,6 +165,8 @@ def fetch_local_events():
|
|
162 |
else:
|
163 |
return "<p>Failed to fetch local events</p>"
|
164 |
|
|
|
|
|
165 |
def fetch_local_weather():
|
166 |
try:
|
167 |
api_key = os.environ['WEATHER_API']
|
|
|
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}'
|
|
|
144 |
<table>
|
145 |
<tr>
|
146 |
<th>Title</th>
|
147 |
+
<th>Date and Time</th>
|
148 |
<th>Location</th>
|
149 |
</tr>
|
150 |
"""
|
151 |
for event in events_results:
|
152 |
title = event.get("title", "No title")
|
153 |
+
date = event.get("date", "No date").replace("start_date", "").replace("when", "").replace("{", "").replace("}", "")
|
154 |
+
location = event.get("address", "No location").replace("[", "").replace("]", "")
|
155 |
link = event.get("link", "#")
|
156 |
events_html += f"""
|
157 |
<tr>
|
|
|
165 |
else:
|
166 |
return "<p>Failed to fetch local events</p>"
|
167 |
|
168 |
+
|
169 |
+
|
170 |
def fetch_local_weather():
|
171 |
try:
|
172 |
api_key = os.environ['WEATHER_API']
|