logging
This commit is contained in:
12
main.py
12
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)
|
||||
|
||||
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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user