jonathanjordan21 commited on
Commit
5b0e283
·
verified ·
1 Parent(s): 409e3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -22,45 +22,45 @@ async def handle_webhook(
22
 
23
 
24
 
25
- @app.post("/webhooks")
26
- async def handle_event_notifications(
27
- request: Request,
28
- x_hub_signature_256: Optional[str] = Header(None) # Header for signature verification
29
- ):
30
- # # Read and verify the request body
31
- # body = await request.body()
32
-
33
- # # Verify the X-Hub-Signature-256 header
34
- # if not x_hub_signature_256:
35
- # raise HTTPException(status_code=400, detail="Missing X-Hub-Signature-256 header")
36
 
37
- # # Compute the expected signature
38
- # expected_signature = (
39
- # "sha256="
40
- # + hmac.new(VERIFY_TOKEN.encode(), body, hashlib.sha256).hexdigest()
41
- # )
42
-
43
- # if not hmac.compare_digest(expected_signature, x_hub_signature_256):
44
- # raise HTTPException(status_code=403, detail="Signature verification failed")
45
- print("POST SUCCESS!", request)
46
- # Parse the JSON payload
47
- payload = await request.json()
48
- print("POST SUCCESS!", request)
49
- print(payload)
50
- object_type = payload.get("object")
51
- entries = payload.get("entry", [])
52
-
53
- # Log the received event (or process as needed)
54
- for entry in entries:
55
- changes = entry.get("changes", [])
56
- for change in changes:
57
- field = change.get("field")
58
- value = change.get("value")
59
- # Handle specific fields or values as required
60
- print(f"Received change for field: {field}, value: {value}")
61
-
62
- # Return a 200 OK response to acknowledge receipt
63
- return {"status": "ok"}
64
 
65
 
66
 
 
22
 
23
 
24
 
25
+ # @app.post("/webhooks")
26
+ # async def handle_event_notifications(
27
+ # request: Request,
28
+ # x_hub_signature_256: Optional[str] = Header(None) # Header for signature verification
29
+ # ):
30
+ # # # Read and verify the request body
31
+ # # body = await request.body()
32
+
33
+ # # # Verify the X-Hub-Signature-256 header
34
+ # # if not x_hub_signature_256:
35
+ # # raise HTTPException(status_code=400, detail="Missing X-Hub-Signature-256 header")
36
 
37
+ # # # Compute the expected signature
38
+ # # expected_signature = (
39
+ # # "sha256="
40
+ # # + hmac.new(VERIFY_TOKEN.encode(), body, hashlib.sha256).hexdigest()
41
+ # # )
42
+
43
+ # # if not hmac.compare_digest(expected_signature, x_hub_signature_256):
44
+ # # raise HTTPException(status_code=403, detail="Signature verification failed")
45
+ # print("POST SUCCESS!", request)
46
+ # # Parse the JSON payload
47
+ # payload = await request.json()
48
+ # print("POST SUCCESS!", request)
49
+ # print(payload)
50
+ # object_type = payload.get("object")
51
+ # entries = payload.get("entry", [])
52
+
53
+ # # Log the received event (or process as needed)
54
+ # for entry in entries:
55
+ # changes = entry.get("changes", [])
56
+ # for change in changes:
57
+ # field = change.get("field")
58
+ # value = change.get("value")
59
+ # # Handle specific fields or values as required
60
+ # print(f"Received change for field: {field}, value: {value}")
61
+
62
+ # # Return a 200 OK response to acknowledge receipt
63
+ # return {"status": "ok"}
64
 
65
 
66