Dump json

This commit is contained in:
Théophile Bastian 2022-03-23 17:00:44 +01:00
parent bc4639a055
commit 2a296c09d1

View file

@ -1,3 +1,4 @@
import json
import typing as t import typing as t
from flask import Flask, request from flask import Flask, request
from . import signal from . import signal
@ -13,6 +14,10 @@ def root() -> t.Tuple[str, int]:
@app.route("/alertmanager", methods=["POST"]) @app.route("/alertmanager", methods=["POST"])
def alertmanager(): def alertmanager():
data = request.get_json(cache=False) data = request.get_json(cache=False)
with open("/tmp/dump.json", "w") as handle:
handle.write(json.dumps(data))
if "version" not in data or int(data["version"]) != 4: if "version" not in data or int(data["version"]) != 4:
return "Bad API version", 400 return "Bad API version", 400
if "alerts" not in data: if "alerts" not in data: