From b16b90e1c1905595c99ae4a988024d858e9d496d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 28 Dec 2023 23:59:46 +0100 Subject: [PATCH] Add API endpoint --- src/render_site.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/render_site.py b/src/render_site.py index edfe8e4..3fa6436 100644 --- a/src/render_site.py +++ b/src/render_site.py @@ -1,4 +1,5 @@ import dataclasses +import json import shutil from pathlib import Path from typing import Dict, List @@ -608,6 +609,13 @@ def render_main_site(env: jinja2.Environment, out_dir: Path): with open(output_file, 'w') as f: f.write(rendered_html) + + # Add API endpoint + output_file = out_dir / 'api' / 'export' / 'games' / 'index.html' + output_file.parent.mkdir(exist_ok=True, parents=True) + with open(output_file, 'w') as f: + json.dump([dataclasses.asdict(g) for g in games], f) + # Copy CSS to output directory shutil.copytree('css', 'build/css', dirs_exist_ok=True) shutil.copytree('deps/tabulator/dist/css', 'build/css', dirs_exist_ok=True)