shortdeck1.0
This commit is contained in:
16
shortdeck_server/persistence.py
Normal file
16
shortdeck_server/persistence.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
DATA_DIR = Path(__file__).parent.joinpath("data")
|
||||
DATA_DIR.mkdir(exist_ok=True)
|
||||
|
||||
|
||||
def append_game_history(game_id, entry):
|
||||
file = DATA_DIR / f"{game_id}.jsonl"
|
||||
with file.open("a", encoding="utf-8") as f:
|
||||
f.write(json.dumps(entry))
|
||||
f.write("\n")
|
||||
|
||||
Reference in New Issue
Block a user