-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebhook.py
More file actions
29 lines (28 loc) · 1.05 KB
/
webhook.py
File metadata and controls
29 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#######################################################################
# dev : awenk audico
# EMAIL SAHIDINAOLA@GMAIL.COM
# WEBSITE https://github.com/FLOWORK-gif/FLOWORK
# File NAME : C:\FLOWORK\webhook.py
# JUMLAH BARIS : 28
#######################################################################
import requests
import json
preset_name = "test-webhook"
url = f"http://localhost:8989/webhook/{preset_name}"
payload = {
"message_from_webhook": "Hello from the Python script!",
"data_source": "Automated Test"
}
headers = {
"Content-Type": "application/json"
}
try:
print(f"Sending POST request to: {url}")
print(f"With data: {json.dumps(payload, indent=2)}")
response = requests.post(url, data=json.dumps(payload), headers=headers)
print(f"\nStatus Code: {response.status_code}")
print("Server Response:")
print(response.json())
except requests.exceptions.ConnectionError as e:
print(f"\n[ERROR] Failed to connect to the server. Make sure the Flowork application is running.")
print(f"Details: {e}")