JAMESPARK3 commited on
Commit
9517d51
Β·
verified Β·
1 Parent(s): 2a3bbe3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -510,14 +510,26 @@ def show_weather_info(data):
510
  st.session_state.weather_data = new_data
511
  st.session_state.last_api_call = datetime.utcnow().timestamp()
512
  st.rerun()
 
 
 
 
513
  with col4:
514
  network_ok = check_network_status()
515
  if not network_ok:
516
- status_color = "#FF0000" # 빨간색
517
  status_text = "λ„€νŠΈμ›Œν¬ μ—°κ²° μ—†μŒ"
518
  else:
519
- status_color = "#00FF00" if not st.session_state.api_failed else "#FF0000" # 녹색 λ˜λŠ” 빨간색
520
- status_text = "API 정상" if not st.session_state.api_failed else "API 응닡 μ—†μŒ"
 
 
 
 
 
 
 
 
521
 
522
  # API μƒνƒœ ν‘œμ‹œλ₯Ό μœ„ν•œ κ³ μœ ν•œ 클래슀λ₯Ό μ‚¬μš©
523
  st.markdown("""
 
510
  st.session_state.weather_data = new_data
511
  st.session_state.last_api_call = datetime.utcnow().timestamp()
512
  st.rerun()
513
+ # session_state에 API μ‹€νŒ¨ μ‹œκ°„ μ €μž₯을 μœ„ν•œ λ³€μˆ˜ μΆ”κ°€
514
+ if 'api_failed_time' not in st.session_state:
515
+ st.session_state.api_failed_time = None
516
+
517
  with col4:
518
  network_ok = check_network_status()
519
  if not network_ok:
520
+ status_color = "#FF0000"
521
  status_text = "λ„€νŠΈμ›Œν¬ μ—°κ²° μ—†μŒ"
522
  else:
523
+ if not st.session_state.api_failed:
524
+ status_color = "#00AA00"
525
+ status_text = "API 정상"
526
+ st.session_state.api_failed_time = None
527
+ else:
528
+ status_color = "#FF0000"
529
+ if st.session_state.api_failed_time is None:
530
+ st.session_state.api_failed_time = datetime.now()
531
+ failed_time = st.session_state.api_failed_time.strftime('%Y-%m-%d %H:%M')
532
+ status_text = f"API 응닡 μ—†μŒ({failed_time} λ°œμƒ)"
533
 
534
  # API μƒνƒœ ν‘œμ‹œλ₯Ό μœ„ν•œ κ³ μœ ν•œ 클래슀λ₯Ό μ‚¬μš©
535
  st.markdown("""