Improve logging

This commit is contained in:
hlohaus
2025-07-13 20:07:39 +02:00
parent a31cb50d6a
commit 6106ca95c9
5 changed files with 56 additions and 16 deletions

View File

@@ -214,6 +214,13 @@ class Backend_Api(Api):
with cache_file.open("a" if cache_file.exists() else "w") as f:
f.write(f"{json.dumps(request.json)}\n")
return {}
@app.route('/backend-api/v2/usage/<date>', methods=['GET'])
def get_usage(date: str):
cache_dir = Path(get_cookies_dir()) / ".usage"
cache_file = cache_dir / f"{date}.jsonl"
print(f"Loading usage data from {cache_file}")
return cache_file.read_text() if cache_file.exists() else (jsonify({"error": {"message": "No usage data found for this date"}}), 404)
@app.route('/backend-api/v2/log', methods=['POST'])
def add_log():