Skip to content

Commit

Permalink
get the json correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnuesslein committed Dec 9, 2024
1 parent 3f05e5b commit 9a5aed3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions knopfler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from starlette.responses import JSONResponse, Response


def format_alert(msg, html=False):
def format_alert(msg:dict, html=False):
try:
alerts = json.loads(msg)["alerts"]
alerts = msg["alerts"]
except:
return f"Error trying to parse JSON!!!\n\n{msg}"
ret = []
Expand Down Expand Up @@ -41,7 +41,7 @@ def get_link(self, channel):
async def link(request: Request):
if request.method == "GET":
return Response("this is just an endpoint for the alertmanager")
room.send_html(format_alert(request.body, html=True))
room.send_html(format_alert(await request.json(), html=True))
return JSONResponse({"status": "ok"})

return link
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "knopfler"
version = "0.1.9"
version = "0.2.1"
description = ""
authors = ["Andreas Nüßlein <[email protected]>"]

Expand Down

0 comments on commit 9a5aed3

Please sign in to comment.