File size: 522 Bytes
35ff4c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import uuid
import json
from pathlib import Path
DATA_FILE = Path("data/motion_ids.json")
def load_ids():
if DATA_FILE.exists():
return json.load(open(DATA_FILE))
return {}
def save_ids(ids):
json.dump(ids, open(DATA_FILE, "w"), indent=2)
def create_motion_id(user_name):
motion_id = str(uuid.uuid4())
ids = load_ids()
ids[motion_id] = {
"name": user_name,
"created_at": str(datetime.datetime.now()),
"usage_count": 0
}
save_ids(ids)
return motion_id |