Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -364,6 +364,90 @@ def fetch_local_events():
|
|
364 |
else:
|
365 |
return "<p>Failed to fetch local events</p>"
|
366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
def fetch_local_weather():
|
368 |
try:
|
369 |
api_key = os.environ['WEATHER_API']
|
@@ -373,7 +457,11 @@ def fetch_local_weather():
|
|
373 |
jsonData = response.json()
|
374 |
|
375 |
current_conditions = jsonData.get("currentConditions", {})
|
376 |
-
|
|
|
|
|
|
|
|
|
377 |
condition = current_conditions.get("conditions", "N/A")
|
378 |
humidity = current_conditions.get("humidity", "N/A")
|
379 |
|
@@ -385,7 +473,7 @@ def fetch_local_weather():
|
|
385 |
<img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
|
386 |
</div>
|
387 |
<div class="weather-details">
|
388 |
-
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {
|
389 |
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
|
390 |
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
|
391 |
</div>
|
@@ -444,6 +532,7 @@ def get_weather_icon(condition):
|
|
444 |
}
|
445 |
return condition_map.get(condition, "c04d")
|
446 |
|
|
|
447 |
# Voice Control
|
448 |
import numpy as np
|
449 |
import torch
|
|
|
364 |
else:
|
365 |
return "<p>Failed to fetch local events</p>"
|
366 |
|
367 |
+
# def fetch_local_weather():
|
368 |
+
# try:
|
369 |
+
# api_key = os.environ['WEATHER_API']
|
370 |
+
# url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/omaha?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
|
371 |
+
# response = requests.get(url)
|
372 |
+
# response.raise_for_status()
|
373 |
+
# jsonData = response.json()
|
374 |
+
|
375 |
+
# current_conditions = jsonData.get("currentConditions", {})
|
376 |
+
# temp = current_conditions.get("temp", "N/A")
|
377 |
+
# condition = current_conditions.get("conditions", "N/A")
|
378 |
+
# humidity = current_conditions.get("humidity", "N/A")
|
379 |
+
|
380 |
+
# weather_html = f"""
|
381 |
+
# <div class="weather-theme">
|
382 |
+
# <h2 style="font-family: 'Georgia', serif; color: #4CAF50; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
|
383 |
+
# <div class="weather-content">
|
384 |
+
# <div class="weather-icon">
|
385 |
+
# <img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
|
386 |
+
# </div>
|
387 |
+
# <div class="weather-details">
|
388 |
+
# <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp}°C</p>
|
389 |
+
# <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
|
390 |
+
# <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
|
391 |
+
# </div>
|
392 |
+
# </div>
|
393 |
+
# </div>
|
394 |
+
# <style>
|
395 |
+
# .weather-theme {{
|
396 |
+
# animation: backgroundAnimation 10s infinite alternate;
|
397 |
+
# border: 1px solid #ddd;
|
398 |
+
# border-radius: 10px;
|
399 |
+
# padding: 10px;
|
400 |
+
# margin-bottom: 15px;
|
401 |
+
# background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
|
402 |
+
# background-size: 400% 400%;
|
403 |
+
# box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
404 |
+
# transition: box-shadow 0.3s ease, background-color 0.3s ease;
|
405 |
+
# }}
|
406 |
+
# .weather-theme:hover {{
|
407 |
+
# box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
|
408 |
+
# background-position: 100% 100%;
|
409 |
+
# }}
|
410 |
+
# @keyframes backgroundAnimation {{
|
411 |
+
# 0% {{ background-position: 0% 50%; }}
|
412 |
+
# 100% {{ background-position: 100% 50%; }}
|
413 |
+
# }}
|
414 |
+
# .weather-content {{
|
415 |
+
# display: flex;
|
416 |
+
# align-items: center;
|
417 |
+
# }}
|
418 |
+
# .weather-icon {{
|
419 |
+
# flex: 1;
|
420 |
+
# }}
|
421 |
+
# .weather-details {{
|
422 |
+
# flex: 3;
|
423 |
+
# }}
|
424 |
+
# </style>
|
425 |
+
# """
|
426 |
+
# return weather_html
|
427 |
+
# except requests.exceptions.RequestException as e:
|
428 |
+
# return f"<p>Failed to fetch local weather: {e}</p>"
|
429 |
+
|
430 |
+
# def get_weather_icon(condition):
|
431 |
+
# condition_map = {
|
432 |
+
# "Clear": "c01d",
|
433 |
+
# "Partly Cloudy": "c02d",
|
434 |
+
# "Cloudy": "c03d",
|
435 |
+
# "Overcast": "c04d",
|
436 |
+
# "Mist": "a01d",
|
437 |
+
# "Patchy rain possible": "r01d",
|
438 |
+
# "Light rain": "r02d",
|
439 |
+
# "Moderate rain": "r03d",
|
440 |
+
# "Heavy rain": "r04d",
|
441 |
+
# "Snow": "s01d",
|
442 |
+
# "Thunderstorm": "t01d",
|
443 |
+
# "Fog": "a05d",
|
444 |
+
# }
|
445 |
+
# return condition_map.get(condition, "c04d")
|
446 |
+
|
447 |
+
|
448 |
+
import os
|
449 |
+
import requests
|
450 |
+
|
451 |
def fetch_local_weather():
|
452 |
try:
|
453 |
api_key = os.environ['WEATHER_API']
|
|
|
457 |
jsonData = response.json()
|
458 |
|
459 |
current_conditions = jsonData.get("currentConditions", {})
|
460 |
+
temp_celsius = current_conditions.get("temp", "N/A")
|
461 |
+
if temp_celsius != "N/A":
|
462 |
+
temp_fahrenheit = (temp_celsius * 9/5) + 32
|
463 |
+
else:
|
464 |
+
temp_fahrenheit = "N/A"
|
465 |
condition = current_conditions.get("conditions", "N/A")
|
466 |
humidity = current_conditions.get("humidity", "N/A")
|
467 |
|
|
|
473 |
<img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
|
474 |
</div>
|
475 |
<div class="weather-details">
|
476 |
+
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp_fahrenheit}°F</p>
|
477 |
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
|
478 |
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
|
479 |
</div>
|
|
|
532 |
}
|
533 |
return condition_map.get(condition, "c04d")
|
534 |
|
535 |
+
|
536 |
# Voice Control
|
537 |
import numpy as np
|
538 |
import torch
|