Add health check API, logging setup, and environment variable support; update requirements and .gitignore

This commit is contained in:
Mabe
2026-08-28 18:44:29 +02:00
parent 36cb2dc567
commit 79e0af79dc
9 changed files with 261 additions and 175 deletions
+16 -1
View File
@@ -1,6 +1,7 @@
import mariadb
import logging
from dotenv import load_dotenv
import os
#Logging
@@ -104,3 +105,17 @@ def delete(cloth_type):
cursor.execute("DELETE FROM luggage WHERE clothes = ?;", (cloth_type,))
logging.critical(f"{cloth_type} was deleted")
connection.commit()
#using .env
load_dotenv()
db_name = os.getenv("DB_NAME")
db_psswd = os.getenv("DB_PASSWORD")
db_user = os.getenv("DB_USER")
db_port = os.getenv("DB_PORT") or "3306"
db_host = os.getenv("DB_HOST")
if db_host == None:
logging.error("no hostname provided")
os._exit(1)
connect(db_user, db_psswd, db_host, int(db_port), db_name)