app.py: GET /api/key-status (step 7)
This commit is contained in:
1 parent
fbb51f59bd
commit
2338b12b1b
1 file changed
+11
@@ -13,6 +13,7 @@ from database import (
|
||||
get_health_check,
|
||||
initialize_database,
|
||||
list_health_checks,
|
||||
list_key_status,
|
||||
list_keys,
|
||||
save_health_check,
|
||||
seed_fixed_keys,
|
||||
@@ -49,6 +50,9 @@ class AppHandler(BaseHTTPRequestHandler):
|
||||
if path == "/api/keys":
|
||||
self._send_keys()
|
||||
return
|
||||
if path == "/api/key-status":
|
||||
self._send_key_status()
|
||||
return
|
||||
if path == "/api/health-checks":
|
||||
self._send_health_check_list()
|
||||
return
|
||||
@@ -114,6 +118,13 @@ class AppHandler(BaseHTTPRequestHandler):
|
||||
except (OSError, sqlite3.Error, ValueError):
|
||||
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):
|
||||
try:
|
||||
self._send_json(200, list_health_checks(get_database_path()))
|
||||
|
||||
Reference in new issue
Block a user