From 18b11eba6c85215419ced7a9474e25c5be62f190 Mon Sep 17 00:00:00 2001 From: Pathompum Jirakarnpaisan <107536914+Saannddy@users.noreply.github.com> Date: Mon, 4 May 2026 23:30:38 +0700 Subject: [PATCH 1/2] fix: update session handling to use SessionFactory for thread-safe operations --- src/core/cheat.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) From 730a05c01e0584cd91845f858fc39ade95f8a705 Mon Sep 17 00:00:00 2001 From: Pathompum Jirakarnpaisan <107536914+Saannddy@users.noreply.github.com> Date: Tue, 5 May 2026 15:47:18 +0700 Subject: [PATCH 2/2] feat: add health check endpoint to return application status --- src/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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')