This commit is contained in:
2026-09-01 15:20:03 +02:00
parent c8b9591441
commit e274ece128
3 changed files with 544 additions and 807 deletions
+31 -1
View File
@@ -16,7 +16,25 @@ from schema_contract import default_config, normalize_training_config, stable_id
from storage import atomic_json_write, utc_now
BASE_DIR = Path(__file__).resolve().parent
DATA_DIR = Path(os.environ.get("DATA_DIR", BASE_DIR / "data")).resolve()
def resolve_data_dir() -> Path:
configured = os.environ.get("DATA_DIR", "").strip()
if configured:
return Path(configured).expanduser().resolve()
suite_data = os.environ.get("BOEHMITOOLS_DATA", "").strip()
for candidate in (
Path("/home/michael/boehmitools/runtime/training/data/trainingsplan"),
Path("/home/michael/runtime/training/data/trainingsplan"),
):
if any((candidate / "plans").glob("*.json")):
return candidate.resolve()
if suite_data:
return (Path(suite_data).expanduser() / "trainingsplan").resolve()
return (BASE_DIR / "data").resolve()
DATA_DIR = resolve_data_dir()
PLANS_DIR = DATA_DIR / "plans"
ACTIVE_FILE = DATA_DIR / "active.txt"
LEGACY_CONFIG = DATA_DIR / "config.json"
@@ -209,6 +227,18 @@ def index():
return Response((STATIC_DIR / "index.html").read_text(encoding="utf-8"), mimetype="text/html")
@app.route("/api/status")
def api_status():
return jsonify({
"name": "Trainingsplan-Backend",
"status": "ok",
"data_dir": str(DATA_DIR),
"plans_dir": str(PLANS_DIR),
"plans": list_plan_ids(),
"active": get_active(),
})
@app.route("/api/plans", methods=["GET"])
def api_plans():
active = get_active()