Tortyfishguy commited on
Commit
c1788ff
·
verified ·
1 Parent(s): 0cad66c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -2,11 +2,9 @@ import os
2
  import threading
3
  import uvicorn
4
  from fastapi import FastAPI, Request, HTTPException, Header
5
- from linebot.v3.messaging import LineBotApi
6
- from linebot.v3.webhook import WebhookHandler
7
- from linebot.v3.exceptions import InvalidSignatureError
8
- from linebot.v3.webhooks import MessageEvent, TextMessage
9
- from linebot.v3.messaging import TextSendMessage
10
  from model import classify_esi # นำเข้าโมเดลสำหรับจัดอันดับ ESI
11
 
12
  # Load environment variables
@@ -26,7 +24,7 @@ async def root():
26
 
27
  @app.post("/webhook")
28
  async def webhook(request: Request, x_line_signature: str = Header(None)):
29
- if x_line_signature is None:
30
  raise HTTPException(status_code=400, detail="Missing X-Line-Signature")
31
 
32
  body = await request.body()
@@ -72,4 +70,3 @@ def get_triage_response(esi_level):
72
 
73
  if __name__ == "__main__":
74
  uvicorn.run(app, host="0.0.0.0", port=7860)
75
-
 
2
  import threading
3
  import uvicorn
4
  from fastapi import FastAPI, Request, HTTPException, Header
5
+ from linebot import LineBotApi, WebhookHandler
6
+ from linebot.exceptions import InvalidSignatureError
7
+ from linebot.models import MessageEvent, TextMessage, TextSendMessage
 
 
8
  from model import classify_esi # นำเข้าโมเดลสำหรับจัดอันดับ ESI
9
 
10
  # Load environment variables
 
24
 
25
  @app.post("/webhook")
26
  async def webhook(request: Request, x_line_signature: str = Header(None)):
27
+ if not x_line_signature:
28
  raise HTTPException(status_code=400, detail="Missing X-Line-Signature")
29
 
30
  body = await request.body()
 
70
 
71
  if __name__ == "__main__":
72
  uvicorn.run(app, host="0.0.0.0", port=7860)