Spaces:
Runtime error
Runtime error
| import json | |
| from pathlib import Path | |
| CTX_PATH = Path('context.json') | |
| def load_context(): | |
| if CTX_PATH.exists(): | |
| try: | |
| return json.loads(CTX_PATH.read_text()) | |
| except Exception: | |
| return {} | |
| return {} | |
| def save_context(ctx: dict): | |
| try: | |
| CTX_PATH.write_text(json.dumps(ctx, indent=2)) | |
| return True | |
| except Exception: | |
| return False | |