Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Query, HTTPException
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
| 5 |
+
VERIFY_TOKEN = "lintasmediadanawa" # Replace with your actual verify token
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
@app.get("/webhooks")
|
| 9 |
+
async def handle_webhook(
|
| 10 |
+
hub_mode: str = Query(..., alias="hub.mode"),
|
| 11 |
+
hub_challenge: int = Query(..., alias="hub.challenge"),
|
| 12 |
+
hub_verify_token: str = Query(..., alias="hub.verify_token")
|
| 13 |
+
):
|
| 14 |
+
if hub_mode == "subscribe" and hub_verify_token == VERIFY_TOKEN:
|
| 15 |
+
return int(hub_challenge)
|
| 16 |
+
else:
|
| 17 |
+
raise HTTPException(status_code=403, detail="Verification failed")
|