From 871b1a5000243b2b3566ec694d63d1e8836d5e1f Mon Sep 17 00:00:00 2001 From: ai-bot Date: Fri, 2 Oct 2026 12:23:49 +0000 Subject: [PATCH] app.py: GET /api/previous-values (section 20) --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index 6043424..20a9dff 100644 --- a/app.py +++ b/app.py @@ -16,6 +16,7 @@ from database import ( list_health_checks, list_key_status, list_keys, + list_previous_values, save_health_check, seed_fixed_keys, ) @@ -56,6 +57,9 @@ class AppHandler(BaseHTTPRequestHandler): if path == "/api/key-status": self._send_key_status() return + if path == "/api/previous-values": + self._send_previous_values() + return if path == "/api/health-checks": self._send_health_check_list() return @@ -131,6 +135,13 @@ class AppHandler(BaseHTTPRequestHandler): except (OSError, sqlite3.Error, ValueError): self._send_json(500, {"error": "Key status is unavailable"}) + def _send_previous_values(self): + """Return the last saved values, so the form can pre-fill itself.""" + try: + self._send_json(200, list_previous_values(get_database_path())) + except (OSError, sqlite3.Error, ValueError): + self._send_json(500, {"error": "Previous values are unavailable"}) + def _send_health_check_list(self): try: self._send_json(200, list_health_checks(get_database_path()))