Pijush2023 commited on
Commit
daa166f
·
verified ·
1 Parent(s): e24c2d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -5
app.py CHANGED
@@ -69,7 +69,7 @@ def get_current_time_and_date():
69
  # Example usage
70
  current_time_and_date = get_current_time_and_date()
71
 
72
- def fetch_local_events():
73
  api_key = os.environ['SERP_API']
74
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
75
 
@@ -87,6 +87,7 @@ def fetch_local_events():
87
  padding: 10px;
88
  border: 1px solid #ddd;
89
  border-radius: 5px;
 
90
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
91
  font-weight: bold;
92
  }
@@ -146,6 +147,74 @@ def fetch_local_events():
146
  else:
147
  return "<p>Failed to fetch local events</p>"
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  def fetch_local_weather():
150
  try:
151
  api_key = os.environ['WEATHER_API']
@@ -182,7 +251,7 @@ def fetch_local_weather():
182
  <style>
183
  .weather-theme {{
184
  animation: backgroundAnimation 10s infinite alternate;
185
- border: 1px solid #ddd;
186
  border-radius: 10px;
187
  padding: 10px;
188
  margin-bottom: 15px;
@@ -214,6 +283,7 @@ def fetch_local_weather():
214
  return weather_html
215
  except requests.exceptions.RequestException as e:
216
  return f"<p>Failed to fetch local weather: {e}</p>"
 
217
  def get_weather_icon(condition):
218
  condition_map = {
219
  "Clear": "c01d",
@@ -375,9 +445,9 @@ def generate_map(location_names):
375
  map_html = m._repr_html_()
376
  return map_html
377
 
378
- def fetch_local_news():
379
  api_key = os.environ['SERP_API']
380
- url = f'https://serpapi.com/search.json?engine=google_news&q=ohama headline&api_key={api_key}'
381
  response = requests.get(url)
382
  if response.status_code == 200:
383
  results = response.json().get("news_results", [])
@@ -390,7 +460,7 @@ def fetch_local_news():
390
  background-color: #f0f8ff;
391
  margin-bottom: 15px;
392
  padding: 10px;
393
- border: 1px solid #ddd;
394
  border-radius: 5px;
395
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
396
  font-weight: bold;
 
69
  # Example usage
70
  current_time_and_date = get_current_time_and_date()
71
 
72
+ # def fetch_local_events():
73
  api_key = os.environ['SERP_API']
74
  url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
75
 
 
87
  padding: 10px;
88
  border: 1px solid #ddd;
89
  border-radius: 5px;
90
+ border: 2px solid red; /* Added red border */
91
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
92
  font-weight: bold;
93
  }
 
147
  else:
148
  return "<p>Failed to fetch local events</p>"
149
 
150
+ # def fetch_local_weather():
151
+ # try:
152
+ # api_key = os.environ['WEATHER_API']
153
+ # url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/omaha?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
154
+ # response = requests.get(url)
155
+ # response.raise_for_status()
156
+ # jsonData = response.json()
157
+
158
+ # current_conditions = jsonData.get("currentConditions", {})
159
+ # temp_celsius = current_conditions.get("temp", "N/A")
160
+
161
+ # if temp_celsius != "N/A":
162
+ # temp_fahrenheit = int((temp_celsius * 9/5) + 32)
163
+ # else:
164
+ # temp_fahrenheit = "N/A"
165
+
166
+ # condition = current_conditions.get("conditions", "N/A")
167
+ # humidity = current_conditions.get("humidity", "N/A")
168
+
169
+ # weather_html = f"""
170
+ # <div class="weather-theme">
171
+ # <h2 style="font-family: 'Georgia', serif; color: #4CAF50; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
172
+ # <div class="weather-content">
173
+ # <div class="weather-icon">
174
+ # <img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
175
+ # </div>
176
+ # <div class="weather-details">
177
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp_fahrenheit}°F</p>
178
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
179
+ # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
180
+ # </div>
181
+ # </div>
182
+ # </div>
183
+ # <style>
184
+ # .weather-theme {{
185
+ # animation: backgroundAnimation 10s infinite alternate;
186
+ # border: 1px solid #ddd;
187
+ # border-radius: 10px;
188
+ # padding: 10px;
189
+ # margin-bottom: 15px;
190
+ # background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
191
+ # background-size: 400% 400%;
192
+ # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
193
+ # transition: box-shadow 0.3s ease, background-color 0.3s ease;
194
+ # }}
195
+ # .weather-theme:hover {{
196
+ # box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
197
+ # background-position: 100% 100%;
198
+ # }}
199
+ # @keyframes backgroundAnimation {{
200
+ # 0% {{ background-position: 0% 50%; }}
201
+ # 100% {{ background-position: 100% 50%; }}
202
+ # }}
203
+ # .weather-content {{
204
+ # display: flex;
205
+ # align-items: center;
206
+ # }}
207
+ # .weather-icon {{
208
+ # flex: 1;
209
+ # }}
210
+ # .weather-details {{
211
+ # flex: 3;
212
+ # }}
213
+ # </style>
214
+ # """
215
+ # return weather_html
216
+ # except requests.exceptions.RequestException as e:
217
+ # return f"<p>Failed to fetch local weather: {e}</p>"
218
  def fetch_local_weather():
219
  try:
220
  api_key = os.environ['WEATHER_API']
 
251
  <style>
252
  .weather-theme {{
253
  animation: backgroundAnimation 10s infinite alternate;
254
+ border: 2px solid red; /* Added red border */
255
  border-radius: 10px;
256
  padding: 10px;
257
  margin-bottom: 15px;
 
283
  return weather_html
284
  except requests.exceptions.RequestException as e:
285
  return f"<p>Failed to fetch local weather: {e}</p>"
286
+
287
  def get_weather_icon(condition):
288
  condition_map = {
289
  "Clear": "c01d",
 
445
  map_html = m._repr_html_()
446
  return map_html
447
 
448
+ # def fetch_local_news():
449
  api_key = os.environ['SERP_API']
450
+ url = f'https://serpapi.com/search.json?engine=google_news&q=omaha headline&api_key={api_key}'
451
  response = requests.get(url)
452
  if response.status_code == 200:
453
  results = response.json().get("news_results", [])
 
460
  background-color: #f0f8ff;
461
  margin-bottom: 15px;
462
  padding: 10px;
463
+ border: 2px solid red; /* Added red border */
464
  border-radius: 5px;
465
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
466
  font-weight: bold;