better message sending
This commit is contained in:
@@ -49,7 +49,7 @@ def _tail(path: Path, line_count: int = 50) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
@app.route(f"{URL_PREFIX}/event", methods=["GET", "POST"])
|
||||
@app.post(f"{URL_PREFIX}/event")
|
||||
def add_event():
|
||||
data = request.get_json(silent=True)
|
||||
if data is None:
|
||||
|
||||
+11
-1
@@ -41,7 +41,17 @@ def send_event(message: dict, event_url: str, timeout: float = 10) -> None:
|
||||
if not event_url:
|
||||
raise ValueError("event_url is required")
|
||||
|
||||
response = requests.post(event_url, json=message, timeout=timeout)
|
||||
response = requests.post(
|
||||
event_url,
|
||||
json=message,
|
||||
timeout=timeout,
|
||||
allow_redirects=False,
|
||||
)
|
||||
if response.is_redirect:
|
||||
raise requests.HTTPError(
|
||||
f"event endpoint redirected to {response.headers.get('Location', '')}",
|
||||
response=response,
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
|
||||
|
||||
@@ -20,3 +20,7 @@
|
||||
2026-08-26T18:22:31+02:00 FIRST_ARRIVAL id=ignace mac=ce:68:53:a8:fc:07
|
||||
2026-08-26T18:28:39+02:00 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
|
||||
2026-08-26T18:28:40+02:00 EMPTY id=house
|
||||
2026-08-26T18:37:21+02:00 ARRIVED id=ignace mac=ce:68:53:a8:fc:07
|
||||
2026-08-26T18:37:21+02:00 FIRST_ARRIVAL id=ignace mac=ce:68:53:a8:fc:07
|
||||
2026-08-26T18:40:07+02:00 DEPARTED id=ignace mac=ce:68:53:a8:fc:07
|
||||
2026-08-26T18:40:07+02:00 EMPTY id=house
|
||||
|
||||
Reference in New Issue
Block a user