Update main.py
Browse files
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 |
-
|
|
|
|
|
39 |
except InvalidSignatureError:
|
40 |
-
|
|
|
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)
|