From ada56f846b9aa226cda31bafe395087d497856f3 Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 24 Jul 2026 11:58:50 +0200 Subject: [PATCH] Self-heal missing data/links.json instead of crashing Production 500'd on every request because the ./data volume mount was an empty host directory, shadowing the seed file baked into the image. load_data() now creates a minimal default file on first run if none exists, so an empty/fresh data volume no longer takes the site down. Co-Authored-By: Claude Sonnet 5 --- app.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app.py b/app.py index e29ceb4..e01ae86 100644 --- a/app.py +++ b/app.py @@ -17,8 +17,23 @@ DATA_FILE = Path(os.environ.get("DATA_FILE", "data/links.json")) COLORS = ["blue", "green", "orange", "pink"] +DEFAULT_DATA = { + "index": { + "title": "My Links", + "subtitle": "", + "subtitle2": "", + "footer_label": "", + "footer_href": "", + "sections": [], + } +} + def load_data(): + if not DATA_FILE.exists(): + DATA_FILE.parent.mkdir(parents=True, exist_ok=True) + save_data(DEFAULT_DATA) + return json.loads(json.dumps(DEFAULT_DATA)) with open(DATA_FILE, "r", encoding="utf-8") as f: return json.load(f)