forked from Hanabi/hanabi-league
Add API endpoint
This commit is contained in:
parent
57a5a6aa35
commit
b16b90e1c1
1 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue