Files
backend/app/utils/cards.py
T

20 lines
531 B
Python
Raw Normal View History

2026-01-02 21:47:28 +08:00
import json
def readCardList() -> dict:
with open("resources/cards/list.json", "r", encoding="utf8") as f:
2026-01-02 21:47:28 +08:00
text = f.read()
result = json.loads(text)
return result
card_list = readCardList()
2026-01-02 21:47:28 +08:00
def readCard(id: str):
path = card_list.get(id, -1)
if (path == -1):
return {"message": f"No Card {id}"}
with open(f"resources/cards/{path}.json", "r", encoding="utf8") as f:
text = f.read()
result = json.loads(text)
return {"message": "OK", "content": result}