alanchen1115 commited on
Commit
7fd59e2
·
verified ·
1 Parent(s): bfdda2a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -2
main.py CHANGED
@@ -34,10 +34,17 @@ def root():
34
 
35
  @app.post("/webhook")
36
  async def webhook(request: Request, x_line_signature: str = Header(None)):
 
 
 
 
37
  try:
38
- line_handler.handle(request.body().decode(), x_line_signature)
 
 
39
  except InvalidSignatureError:
40
- raise HTTPException(status_code=400, detail="chatbot handle body error.")
 
41
  return 'OK'
42
 
43
  @line_handler.add(MessageEvent, message=TextMessage)
 
34
 
35
  @app.post("/webhook")
36
  async def webhook(request: Request, x_line_signature: str = Header(None)):
37
+ signature = request.headers['X-Line-Signature']
38
+
39
+ body = request.get_data(as_text=True)
40
+ app.logger.info("Request body: " + body)
41
  try:
42
+ print(body, signature)
43
+ handler.handle(body, signature)
44
+
45
  except InvalidSignatureError:
46
+ abort(400)
47
+
48
  return 'OK'
49
 
50
  @line_handler.add(MessageEvent, message=TextMessage)