Files
watcher/Tests/servicediscovery.py

29 lines
690 B
Python

import json
import urllib.request
url = "http://localhost:5000/monitoring/ServiceDetection"
payload = {
"server_id": 2,
"containers": [
{"ContainerId": "hr1nm432143nkj", "Name": "Name des Containers", "Image": "ghcr.io/test/container:latest"}
]
}
data = json.dumps(payload).encode("utf-8")
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json"},
method="POST"
)
try:
with urllib.request.urlopen(req) as response:
resp_data = response.read().decode("utf-8")
print("Status Code:", response.status)
print("Response:", resp_data)
except Exception as e:
print("Fehler beim Senden der Request:", e)