cwadayi commited on
Commit
2c49505
·
verified ·
1 Parent(s): 4c372eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -22,7 +22,7 @@ app = Flask(__name__)
22
  configuration = Configuration(access_token=CHANNEL_ACCESS_TOKEN)
23
  handler = WebhookHandler(CHANNEL_SECRET)
24
 
25
- # --- 地震查詢核心邏輯 (與之前相同) ---
26
  USGS_API_BASE_URL = "https://earthquake.usgs.gov/fdsnws/event/1/query"
27
 
28
  def fetch_earthquake_data_for_line():
@@ -36,7 +36,7 @@ def fetch_earthquake_data_for_line():
36
  "endtime": now.strftime('%Y-%m-%d'),
37
  "minmagnitude": 5.0,
38
  "limit": 10,
39
- "orderby": "time-desc"
40
  }
41
 
42
  try:
@@ -65,6 +65,7 @@ def fetch_earthquake_data_for_line():
65
  except Exception as e:
66
  return f"❌ 處理資料時發生未知錯誤: {e}"
67
 
 
68
  # --- Flask Webhook 路由 ---
69
  @app.route("/callback", methods=['POST'])
70
  def callback():
@@ -79,6 +80,7 @@ def callback():
79
  abort(400)
80
  return 'OK'
81
 
 
82
  # --- LINE 訊息處理 ---
83
  @handler.add(MessageEvent, message=TextMessageContent)
84
  def handle_message(event):
@@ -100,5 +102,3 @@ def handle_message(event):
100
  messages=[TextMessage(text=reply_text)]
101
  )
102
  )
103
-
104
- # 注意:我們已經刪除了 if __name__ == "__main__": app.run() 區塊
 
22
  configuration = Configuration(access_token=CHANNEL_ACCESS_TOKEN)
23
  handler = WebhookHandler(CHANNEL_SECRET)
24
 
25
+ # --- 地震查詢核心邏輯 ---
26
  USGS_API_BASE_URL = "https://earthquake.usgs.gov/fdsnws/event/1/query"
27
 
28
  def fetch_earthquake_data_for_line():
 
36
  "endtime": now.strftime('%Y-%m-%d'),
37
  "minmagnitude": 5.0,
38
  "limit": 10,
39
+ "orderby": "time" # 💡💡💡 修正點:將 "time-desc" 改為 "time" 💡💡💡
40
  }
41
 
42
  try:
 
65
  except Exception as e:
66
  return f"❌ 處理資料時發生未知錯誤: {e}"
67
 
68
+
69
  # --- Flask Webhook 路由 ---
70
  @app.route("/callback", methods=['POST'])
71
  def callback():
 
80
  abort(400)
81
  return 'OK'
82
 
83
+
84
  # --- LINE 訊息處理 ---
85
  @handler.add(MessageEvent, message=TextMessageContent)
86
  def handle_message(event):
 
102
  messages=[TextMessage(text=reply_text)]
103
  )
104
  )