JAMESPARK3 commited on
Commit
e234022
ยท
verified ยท
1 Parent(s): fef2b07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -455,7 +455,28 @@ def show_weather_info(data):
455
  """
456
  components.html(clock_html, height=300)
457
 
458
- st.button("์‹œ๊ฐ„๋Œ€๋ณ„ ์˜จ๋„ ๋ณด๊ธฐ", on_click=lambda: st.session_state.update({'current_section': 'temperature'}))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)