app.py: GET /api/key-status (step 7)

This commit is contained in:
ai-bot committed 2026-10-02 09:20:17 +00:00
1 parent fbb51f59bd
commit 2338b12b1b
1 file changed
+11
+11
View File
@@ -13,6 +13,7 @@ from database import (
get_health_check, get_health_check,
initialize_database, initialize_database,
list_health_checks, list_health_checks,
list_key_status,
list_keys, list_keys,
save_health_check, save_health_check,
seed_fixed_keys, seed_fixed_keys,
@@ -49,6 +50,9 @@ class AppHandler(BaseHTTPRequestHandler):
if path == "/api/keys": if path == "/api/keys":
self._send_keys() self._send_keys()
return return
if path == "/api/key-status":
self._send_key_status()
return
if path == "/api/health-checks": if path == "/api/health-checks":
self._send_health_check_list() self._send_health_check_list()
return return
@@ -114,6 +118,13 @@ class AppHandler(BaseHTTPRequestHandler):
except (OSError, sqlite3.Error, ValueError): except (OSError, sqlite3.Error, ValueError):
self._send_json(500, {"error": "Key profiles are unavailable"}) self._send_json(500, {"error": "Key profiles are unavailable"})
def _send_key_status(self):
"""Return each key with the dates of its newest saved check."""
try:
self._send_json(200, list_key_status(get_database_path()))
except (OSError, sqlite3.Error, ValueError):
self._send_json(500, {"error": "Key status is unavailable"})
def _send_health_check_list(self): def _send_health_check_list(self):
try: try:
self._send_json(200, list_health_checks(get_database_path())) self._send_json(200, list_health_checks(get_database_path()))