Add API endpoint

This commit is contained in:
Maximilian Keßler 2023-12-28 23:59:46 +01:00
parent 57a5a6aa35
commit b16b90e1c1
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -1,4 +1,5 @@
import dataclasses import dataclasses
import json
import shutil import shutil
from pathlib import Path from pathlib import Path
from typing import Dict, List 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: with open(output_file, 'w') as f:
f.write(rendered_html) 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 # Copy CSS to output directory
shutil.copytree('css', 'build/css', dirs_exist_ok=True) shutil.copytree('css', 'build/css', dirs_exist_ok=True)
shutil.copytree('deps/tabulator/dist/css', 'build/css', dirs_exist_ok=True) shutil.copytree('deps/tabulator/dist/css', 'build/css', dirs_exist_ok=True)