diff --git a/app.py b/app.py index 6d9468a..a654e2b 100644 --- a/app.py +++ b/app.py @@ -116,8 +116,18 @@ BASE_DIR = Path(__file__).resolve().parent app = FastAPI() templates = Jinja2Templates(directory=str(BASE_DIR / "templates")) app.mount("/static", StaticFiles(directory=str(BASE_DIR / "static")), name="static") -run_scheduler() +@app.on_event("startup") +def start_scheduler(): + import threading + + thread = threading.Thread( + target=run_scheduler, + daemon=True + ) + thread.start() + + class PublishVmixCommandPayload(BaseModel): match_id: int session_token: str | None = None @@ -487,39 +497,6 @@ def admin_matches( }, ) - -# @app.get("/admin/matches/{match_id}/select") -# def select_match( -# request: Request, match_id: int, operator_name: str = Form(default="") -# ): -# match_row = get_match_by_id(match_id) -# if not match_row: -# return RedirectResponse(url="/admin/matches", status_code=303) - -# _, match_external_id, _, _, _, _, _ = match_row - -# vmix_result = prepare_vmix_project(match_row) - -# session_row = create_match_session( -# match_id=match_id, -# operator_name=operator_name.strip() or None, -# vmix_project_path=( -# vmix_result["project_path"] if vmix_result["success"] else None -# ), -# ) - -# session_token = session_row[3] -# log_action( -# request, -# action="match_selected", -# entity_type="match", -# entity_id=match_id, -# match_id=match_id, -# session_token=session_row[3], -# details={"operator_name": operator_name.strip() or None}, -# ) -# return RedirectResponse(url=f"/admin/session/{session_token}", status_code=303) - @app.get("/admin/matches/{match_id}/select") def select_match(