Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -455,7 +455,28 @@ def show_weather_info(data):
|
|
| 455 |
"""
|
| 456 |
components.html(clock_html, height=300)
|
| 457 |
|
| 458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
|
| 460 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 461 |
|
|
@@ -755,6 +776,7 @@ def main():
|
|
| 755 |
st.session_state.current_section = 'weather'
|
| 756 |
st.session_state.last_api_call = 0
|
| 757 |
st.session_state.weather_data = None
|
|
|
|
| 758 |
|
| 759 |
# ํ์ฌ ์๊ฐ์ ์์ธ ์๊ฐ์ผ๋ก ๊ฐ์ ธ์ต๋๋ค.
|
| 760 |
current_time = datetime.utcnow() + timedelta(hours=9)
|
|
|
|
| 455 |
"""
|
| 456 |
components.html(clock_html, height=300)
|
| 457 |
|
| 458 |
+
# API ํ
์คํธ ๋ฒํผ
|
| 459 |
+
col1, col2, col3 = st.columns([1, 1, 2])
|
| 460 |
+
with col1:
|
| 461 |
+
st.button("์๊ฐ๋๋ณ ์จ๋ ๋ณด๊ธฐ", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
|
| 462 |
+
with col2:
|
| 463 |
+
if st.button("API ์๋ต ์ฒดํฌ"):
|
| 464 |
+
new_data = get_weather_data()
|
| 465 |
+
if new_data:
|
| 466 |
+
st.session_state.api_failed = False
|
| 467 |
+
st.session_state.weather_data = new_data
|
| 468 |
+
st.session_state.last_api_call = datetime.utcnow().timestamp()
|
| 469 |
+
st.rerun()
|
| 470 |
+
with col3:
|
| 471 |
+
network_ok = check_network_status()
|
| 472 |
+
if not network_ok:
|
| 473 |
+
status_color = "red"
|
| 474 |
+
status_text = "๋คํธ์ํฌ ์ฐ๊ฒฐ ์์"
|
| 475 |
+
else:
|
| 476 |
+
status_color = "green" if not st.session_state.api_failed else "red"
|
| 477 |
+
status_text = "API ์ ์" if not st.session_state.api_failed else "API ์๋ต ์์"
|
| 478 |
+
st.markdown(f'<p style="color:{status_color}; font-size:20px; font-weight:bold;">{status_text}</p>', unsafe_allow_html=True)
|
| 479 |
+
|
| 480 |
|
| 481 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 482 |
|
|
|
|
| 776 |
st.session_state.current_section = 'weather'
|
| 777 |
st.session_state.last_api_call = 0
|
| 778 |
st.session_state.weather_data = None
|
| 779 |
+
st.session_state.api_failed = False # api_failed ์ด๊ธฐํ ์ถ๊ฐ
|
| 780 |
|
| 781 |
# ํ์ฌ ์๊ฐ์ ์์ธ ์๊ฐ์ผ๋ก ๊ฐ์ ธ์ต๋๋ค.
|
| 782 |
current_time = datetime.utcnow() + timedelta(hours=9)
|