diff --git a/src/app.py b/src/app.py index ff31b0c..cf05502 100644 --- a/src/app.py +++ b/src/app.py @@ -1,5 +1,5 @@ import logging -from flask import Flask +from flask import Flask, jsonify from api import api_bp logging.basicConfig(level=logging.INFO) @@ -10,6 +10,10 @@ def create_app(): # Register routes app.register_blueprint(api_bp) + @app.route('/health') + def health(): + return jsonify(status='success', data={'health': 'ok'}), 200 + @app.route('/') def home(): return app.send_static_file('index.html') diff --git a/src/core/cheat.py b/src/core/cheat.py index 337bea2..6d2145b 100644 --- a/src/core/cheat.py +++ b/src/core/cheat.py @@ -17,7 +17,7 @@ import threading from sqlmodel import select -from infrastructure import SessionLocal +from infrastructure import SessionLocal as SessionFactory from models import CheatMode _lock = threading.Lock() @@ -51,10 +51,10 @@ def _constant_time_verify(raw_input: str, stored_hash: str) -> bool: def is_cheat_mode() -> bool: """Return current cheat mode state (thread-safe read).""" with _lock: - if not SessionLocal: + if not SessionFactory: return False - with SessionLocal() as session: + with SessionFactory() as session: return _get_cheat_row(session).enabled @@ -80,7 +80,7 @@ def toggle_cheat_mode(raw_cheat_code: str) -> dict: "cheat_mode": None, } - if not SessionLocal: + if not SessionFactory: return { "success": False, "message": "Database is not configured for cheat mode storage.", @@ -88,7 +88,7 @@ def toggle_cheat_mode(raw_cheat_code: str) -> dict: } with _lock: - with SessionLocal() as session: + with SessionFactory() as session: cheat = _get_cheat_row(session) cheat.enabled = not cheat.enabled session.add(cheat)