Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -431,7 +431,7 @@ def show_weather_info(data):
|
|
| 431 |
st.markdown(f'''
|
| 432 |
<div class="time-container">
|
| 433 |
<div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">
|
| 434 |
-
{temp}{precip_mark} {tomorrow_morning_weather}
|
| 435 |
</div>
|
| 436 |
<span class="date-text">{formatted_date}</span>
|
| 437 |
</div>
|
|
@@ -462,10 +462,14 @@ def show_weather_info(data):
|
|
| 462 |
components.html(clock_html, height=300)
|
| 463 |
|
| 464 |
# API ν
μ€νΈ λ²νΌ
|
| 465 |
-
|
|
|
|
| 466 |
with col1:
|
| 467 |
-
st.button("
|
|
|
|
| 468 |
with col2:
|
|
|
|
|
|
|
| 469 |
if st.button("API μλ΅ μ²΄ν¬"):
|
| 470 |
new_data = get_weather_data()
|
| 471 |
if new_data:
|
|
@@ -473,7 +477,7 @@ def show_weather_info(data):
|
|
| 473 |
st.session_state.weather_data = new_data
|
| 474 |
st.session_state.last_api_call = datetime.utcnow().timestamp()
|
| 475 |
st.rerun()
|
| 476 |
-
with
|
| 477 |
network_ok = check_network_status()
|
| 478 |
if not network_ok:
|
| 479 |
status_color = "red"
|
|
@@ -517,18 +521,18 @@ def show_weather_info(data):
|
|
| 517 |
weather_descriptions.append(description)
|
| 518 |
|
| 519 |
# λ μ¨ μ보 μμ± λ° νμ
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
|
| 529 |
# μ μ₯λ λ μ¨ μ보 νμ
|
| 530 |
st.markdown(f'''
|
| 531 |
-
<div class="scroll-container">
|
| 532 |
<div class="scroll-text">{st.session_state.weather_forecast}</div>
|
| 533 |
</div>
|
| 534 |
''', unsafe_allow_html=True)
|
|
@@ -831,7 +835,9 @@ def main():
|
|
| 831 |
st.session_state.current_section = 'weather'
|
| 832 |
st.session_state.last_api_call = 0
|
| 833 |
st.session_state.weather_data = None
|
| 834 |
-
st.session_state.api_failed = False
|
|
|
|
|
|
|
| 835 |
|
| 836 |
# νμ¬ μκ°μ μμΈ μκ°μΌλ‘ κ°μ Έμ΅λλ€.
|
| 837 |
current_time = datetime.utcnow() + timedelta(hours=9)
|
|
|
|
| 431 |
st.markdown(f'''
|
| 432 |
<div class="time-container">
|
| 433 |
<div style="text-align: center; margin-bottom: 0.5rem; font-size: 6em; font-weight: bold; color: black;">
|
| 434 |
+
{temp}{precip_mark} {tomorrow_morning_weather}
|
| 435 |
</div>
|
| 436 |
<span class="date-text">{formatted_date}</span>
|
| 437 |
</div>
|
|
|
|
| 462 |
components.html(clock_html, height=300)
|
| 463 |
|
| 464 |
# API ν
μ€νΈ λ²νΌ
|
| 465 |
+
# show_weather_info() ν¨μμ λ²νΌ λΆλΆ μμ
|
| 466 |
+
col1, col2, col3, col4 = st.columns([1, 1, 1, 2])
|
| 467 |
with col1:
|
| 468 |
+
if st.button("λ μ¨ μ보 μ€ν¬λ‘€", key="toggle_scroll"):
|
| 469 |
+
st.session_state.scroll_visible = not st.session_state.scroll_visible
|
| 470 |
with col2:
|
| 471 |
+
st.button("μκ°λλ³ μ¨λ 보기", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
|
| 472 |
+
with col3:
|
| 473 |
if st.button("API μλ΅ μ²΄ν¬"):
|
| 474 |
new_data = get_weather_data()
|
| 475 |
if new_data:
|
|
|
|
| 477 |
st.session_state.weather_data = new_data
|
| 478 |
st.session_state.last_api_call = datetime.utcnow().timestamp()
|
| 479 |
st.rerun()
|
| 480 |
+
with col4:
|
| 481 |
network_ok = check_network_status()
|
| 482 |
if not network_ok:
|
| 483 |
status_color = "red"
|
|
|
|
| 521 |
weather_descriptions.append(description)
|
| 522 |
|
| 523 |
# λ μ¨ μ보 μμ± λ° νμ
|
| 524 |
+
background_color = get_background_color(data['PM10'])
|
| 525 |
+
scroll_style = """
|
| 526 |
+
background-color: rgba(255, 255, 255, 0.9);
|
| 527 |
+
color: #333;
|
| 528 |
+
""" if st.session_state.scroll_visible else f"""
|
| 529 |
+
background-color: {background_color};
|
| 530 |
+
color: {background_color};
|
| 531 |
+
"""
|
| 532 |
|
| 533 |
# μ μ₯λ λ μ¨ μ보 νμ
|
| 534 |
st.markdown(f'''
|
| 535 |
+
<div class="scroll-container" style="{scroll_style}">
|
| 536 |
<div class="scroll-text">{st.session_state.weather_forecast}</div>
|
| 537 |
</div>
|
| 538 |
''', unsafe_allow_html=True)
|
|
|
|
| 835 |
st.session_state.current_section = 'weather'
|
| 836 |
st.session_state.last_api_call = 0
|
| 837 |
st.session_state.weather_data = None
|
| 838 |
+
st.session_state.api_failed = False
|
| 839 |
+
st.session_state.scroll_visible = False
|
| 840 |
+
st.session_state.weather_forecast = "" # weather_forecast μ΄κΈ°ν μΆκ°
|
| 841 |
|
| 842 |
# νμ¬ μκ°μ μμΈ μκ°μΌλ‘ κ°μ Έμ΅λλ€.
|
| 843 |
current_time = datetime.utcnow() + timedelta(hours=9)
|