Spaces:
Sleeping
Sleeping
John Landry
commited on
Commit
•
a46ecf2
1
Parent(s):
bca2aec
added webhooks
Browse files
main.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI
|
2 |
import logging
|
3 |
|
4 |
logger = logging.getLogger()
|
@@ -15,8 +15,23 @@ def hello():
|
|
15 |
print('hello log')
|
16 |
return {'hello': 'world'}
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
@app.post("/webhook")
|
19 |
-
def
|
20 |
-
|
21 |
-
|
|
|
22 |
|
|
|
1 |
+
from fastapi import FastAPI, Request, Query
|
2 |
import logging
|
3 |
|
4 |
logger = logging.getLogger()
|
|
|
15 |
print('hello log')
|
16 |
return {'hello': 'world'}
|
17 |
|
18 |
+
@app.webhooks.post("whatsappmsg")
|
19 |
+
def get_entities(request: Request):
|
20 |
+
print(request)
|
21 |
+
return f"INPUT: {request.body}"
|
22 |
+
|
23 |
+
@app.get("/webook")
|
24 |
+
async def ping(
|
25 |
+
token: str = Query(alias="hub.verify_token"),
|
26 |
+
challenge: str = Query(alias="hub.challenge"),
|
27 |
+
):
|
28 |
+
if token.lower() == "jericlandry":
|
29 |
+
return challenge
|
30 |
+
return "Invalid verify token"
|
31 |
+
|
32 |
@app.post("/webhook")
|
33 |
+
async def root(request: Request):
|
34 |
+
data = await request.json()
|
35 |
+
print(data)
|
36 |
+
return "Success"
|
37 |
|