cwadayi commited on
Commit
cc337b3
·
verified ·
1 Parent(s): 3aab70e

Upload 15 files

Browse files
services/cwa_service.py CHANGED
@@ -3,7 +3,8 @@ import requests
3
  import re
4
  import pandas as pd
5
  from datetime import datetime, timedelta, timezone
6
- from config import CWA_API_KEY, CWA_ALARM_API, CWA_SIGNIFICANT_API
 
7
 
8
  TAIPEI_TZ = timezone(timedelta(hours=8))
9
 
@@ -145,5 +146,4 @@ def fetch_latest_significant_earthquake() -> dict | None:
145
 
146
  return latest_eq_data
147
  except Exception as e:
148
- raise e
149
-
 
3
  import re
4
  import pandas as pd
5
  from datetime import datetime, timedelta, timezone
6
+ # CORRECTED IMPORT
7
+ from config.settings import CWA_API_KEY, CWA_ALARM_API, CWA_SIGNIFICANT_API
8
 
9
  TAIPEI_TZ = timezone(timedelta(hours=8))
10
 
 
146
 
147
  return latest_eq_data
148
  except Exception as e:
149
+ raise e
 
services/news_service.py CHANGED
@@ -2,9 +2,8 @@
2
  import requests
3
  import json
4
  from datetime import datetime
5
-
6
- # config.py 匯入 API URL
7
- from config import PTS_NEWS_API
8
 
9
  def fetch_today_news() -> str:
10
  """
 
2
  import requests
3
  import json
4
  from datetime import datetime
5
+ # ✨ CORRECTED IMPORT
6
+ from config.settings import PTS_NEWS_API
 
7
 
8
  def fetch_today_news() -> str:
9
  """
services/pws_service.py CHANGED
@@ -2,7 +2,8 @@
2
  import requests
3
  import json
4
  from datetime import datetime
5
- from config import PWS_API_URL, CWA_PWS_EARTHQUAKE_API
 
6
 
7
  def fetch_latest_pws_info() -> str:
8
  """
 
2
  import requests
3
  import json
4
  from datetime import datetime
5
+ # CORRECTED IMPORT
6
+ from config.settings import PWS_API_URL, CWA_PWS_EARTHQUAKE_API
7
 
8
  def fetch_latest_pws_info() -> str:
9
  """
services/usgs_service.py CHANGED
@@ -2,7 +2,8 @@
2
  import requests
3
  import pandas as pd
4
  from datetime import datetime, timedelta, timezone
5
- from config import USGS_API_BASE_URL, CURRENT_YEAR
 
6
 
7
  def _iso(dt: datetime) -> str:
8
  """將 datetime 物件格式化為 USGS API 需要的 ISO 8601 字串。"""
@@ -75,4 +76,4 @@ def fetch_taiwan_df_this_year(min_mag: float = 5.0) -> pd.DataFrame | str:
75
  })
76
  return pd.DataFrame(rows)
77
  except Exception as e:
78
- return f"❌ 查詢失敗: {e}"
 
2
  import requests
3
  import pandas as pd
4
  from datetime import datetime, timedelta, timezone
5
+ # CORRECTED IMPORT
6
+ from config.settings import USGS_API_BASE_URL, CURRENT_YEAR
7
 
8
  def _iso(dt: datetime) -> str:
9
  """將 datetime 物件格式化為 USGS API 需要的 ISO 8601 字串。"""
 
76
  })
77
  return pd.DataFrame(rows)
78
  except Exception as e:
79
+ return f"❌ 查詢失敗: {e}"