diff --git a/main.py b/main.py index f096e80..13344f8 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,12 @@ from flask import Flask, request import httpx +import logging app = Flask(__name__) +# Configure logging +logging.basicConfig(level=logging.INFO) + def populate_webhook_lookup(): lookup = {} @@ -53,8 +57,16 @@ def convert(uuid): ghost_payload = request.get_json() discord_payload = convert_ghost_to_discord(ghost_payload) - r = httpx.post(webhook, json=discord_payload) - print(r) + try: + r = httpx.post(webhook, json=discord_payload) + if r.status_code == 200: + logging.info(f"Successfully posted to Discord webhook for UUID {uuid}") + else: + logging.warning(f"Discord webhook POST failed for UUID {uuid} with status {r.status_code}: {r.text}") + print(r) + except Exception as e: + logging.error(f"Failed to post to Discord webhook for UUID {uuid}: {str(e)}") + return "error", 500 return "yay"