File size: 2,308 Bytes
71591d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# config/settings.py
import os
import tempfile
from datetime import datetime

# ==============================================================================
# 1. 執行環境設定 (適用於 Hugging Face Spaces)
# ==============================================================================

# 設定一個暫存目錄給 Matplotlib 快取字體 (若未來有繪圖功能)
os.environ.setdefault("MPLCONFIGDIR", "/tmp/matplotlib")

# 定義一個暫存目錄來存放生成的靜態檔案
STATIC_DIR = os.getenv("STATIC_DIR", os.path.join(tempfile.gettempdir(), "static"))
os.makedirs(STATIC_DIR, exist_ok=True)


# ==============================================================================
# 2. 憑證與金鑰 (從 Secret Variables 讀取)
# ==============================================================================

# LINE Bot 憑證
CHANNEL_ACCESS_TOKEN = os.getenv("CHANNEL_ACCESS_TOKEN")
CHANNEL_SECRET = os.getenv("CHANNEL_SECRET")

# CWA (中央氣象署) API 金鑰
CWA_API_KEY = os.getenv("CWA_API_KEY")

# Google Gemini API 金鑰
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")


# ==============================================================================
# 3. API 端點與 URL
# ==============================================================================

# CWA API 端點
CWA_ALARM_API = "https://app-2.cwa.gov.tw/api/v1/earthquake/alarm/list"
CWA_SIGNIFICANT_API = "https://opendata.cwa.gov.tw/api/v1/rest/datastore/E-A0015-001"

# USGS API 端點
USGS_API_BASE_URL = "https://earthquake.usgs.gov/fdsnws/event/1/query"

# MCP 伺服器 (Gradio App) URL
MCP_SERVER_URL = "https://cwadayi-mcp-2.hf.space"# MCP 伺服器 (Gradio App) URL

# [新增] PWS 伺服器 API 端點
PWS_API_URL = "https://cwadayi-mcp-pws.hf.space/gradio_api/mcp/sse"


# CWA PWS 地震訊息 API 端點
CWA_PWS_EARTHQUAKE_API = "https://cwadayi-app-show-pws.hf.space/cwa-earthquakes"

# [新增] PTS 新聞 API 端點
PTS_NEWS_API = "https://cwadayi-app-show-news.hf.space/pts-news"


# ==============================================================================
# 4. 一般應用程式設定
# ==============================================================================

# 顯示用的當年年份
CURRENT_YEAR = datetime.now().year