Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -348,16 +348,85 @@ def fetch_local_weather():
|
|
348 |
temp = current_conditions.get("temp", "N/A")
|
349 |
condition = current_conditions.get("conditions", "N/A")
|
350 |
humidity = current_conditions.get("humidity", "N/A")
|
351 |
-
|
352 |
-
weather_html = f"
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
return weather_html
|
358 |
except requests.exceptions.RequestException as e:
|
359 |
return f"<p>Failed to fetch local weather: {e}</p>"
|
360 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
# Voice Control
|
362 |
import numpy as np
|
363 |
import torch
|
@@ -462,8 +531,8 @@ with gr.Blocks(theme='rawrsor1/Everforest') as demo:
|
|
462 |
''')
|
463 |
chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
|
464 |
|
465 |
-
|
466 |
-
|
467 |
|
468 |
with gr.Column():
|
469 |
news_output = gr.HTML(value=fetch_local_news())
|
|
|
348 |
temp = current_conditions.get("temp", "N/A")
|
349 |
condition = current_conditions.get("conditions", "N/A")
|
350 |
humidity = current_conditions.get("humidity", "N/A")
|
351 |
+
|
352 |
+
weather_html = f"""
|
353 |
+
<div class="weather-theme">
|
354 |
+
<h2 style="font-family: 'Georgia', serif; color: #4CAF50; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
|
355 |
+
<div class="weather-content">
|
356 |
+
<div class="weather-icon">
|
357 |
+
<img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
|
358 |
+
</div>
|
359 |
+
<div class="weather-details">
|
360 |
+
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp}°C</p>
|
361 |
+
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
|
362 |
+
<p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
|
363 |
+
</div>
|
364 |
+
</div>
|
365 |
+
</div>
|
366 |
+
<style>
|
367 |
+
.weather-theme {
|
368 |
+
animation: backgroundAnimation 10s infinite alternate;
|
369 |
+
border: 1px solid #ddd;
|
370 |
+
border-radius: 10px;
|
371 |
+
padding: 10px;
|
372 |
+
margin-bottom: 15px;
|
373 |
+
background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
|
374 |
+
background-size: 400% 400%;
|
375 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
376 |
+
transition: box-shadow 0.3s ease, background-color 0.3s ease;
|
377 |
+
}
|
378 |
+
.weather-theme:hover {
|
379 |
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
|
380 |
+
background-position: 100% 100%;
|
381 |
+
}
|
382 |
+
@keyframes backgroundAnimation {
|
383 |
+
0% { background-position: 0% 50%; }
|
384 |
+
100% { background-position: 100% 50%; }
|
385 |
+
}
|
386 |
+
.weather-content {
|
387 |
+
display: flex;
|
388 |
+
align-items: center;
|
389 |
+
}
|
390 |
+
.weather-icon {
|
391 |
+
flex: 1;
|
392 |
+
}
|
393 |
+
.weather-details {
|
394 |
+
flex: 3;
|
395 |
+
}
|
396 |
+
</style>
|
397 |
+
"""
|
398 |
return weather_html
|
399 |
except requests.exceptions.RequestException as e:
|
400 |
return f"<p>Failed to fetch local weather: {e}</p>"
|
401 |
|
402 |
+
def get_weather_icon(condition):
|
403 |
+
condition_map = {
|
404 |
+
"Clear": "c01d",
|
405 |
+
"Partly Cloudy": "c02d",
|
406 |
+
"Cloudy": "c03d",
|
407 |
+
"Overcast": "c04d",
|
408 |
+
"Mist": "a01d",
|
409 |
+
"Patchy rain possible": "r01d",
|
410 |
+
"Light rain": "r02d",
|
411 |
+
"Moderate rain": "r03d",
|
412 |
+
"Heavy rain": "r04d",
|
413 |
+
"Snow": "s01d",
|
414 |
+
"Thunderstorm": "t01d",
|
415 |
+
"Fog": "a05d",
|
416 |
+
}
|
417 |
+
return condition_map.get(condition, "c01d")
|
418 |
+
|
419 |
+
|
420 |
+
|
421 |
+
# weather_html = f"<h2>Local Weather</h2>"
|
422 |
+
# weather_html += f"<p>Temperature: {temp}°C</p>"
|
423 |
+
# weather_html += f"<p>Condition: {condition}</p>"
|
424 |
+
# weather_html += f"<p>Humidity: {humidity}%</p>"
|
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 |
# Voice Control
|
431 |
import numpy as np
|
432 |
import torch
|
|
|
531 |
''')
|
532 |
chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
|
533 |
|
534 |
+
with gr.Column():
|
535 |
+
weather_output = gr.HTML(value=fetch_local_weather())
|
536 |
|
537 |
with gr.Column():
|
538 |
news_output = gr.HTML(value=fetch_local_news())
|