app.py: GET /api/previous-values (section 20)
This commit is contained in:
1 parent
08819af6d1
commit
871b1a5000
1 file changed
+11
@@ -16,6 +16,7 @@ from database import (
|
|||||||
list_health_checks,
|
list_health_checks,
|
||||||
list_key_status,
|
list_key_status,
|
||||||
list_keys,
|
list_keys,
|
||||||
|
list_previous_values,
|
||||||
save_health_check,
|
save_health_check,
|
||||||
seed_fixed_keys,
|
seed_fixed_keys,
|
||||||
)
|
)
|
||||||
@@ -56,6 +57,9 @@ class AppHandler(BaseHTTPRequestHandler):
|
|||||||
if path == "/api/key-status":
|
if path == "/api/key-status":
|
||||||
self._send_key_status()
|
self._send_key_status()
|
||||||
return
|
return
|
||||||
|
if path == "/api/previous-values":
|
||||||
|
self._send_previous_values()
|
||||||
|
return
|
||||||
if path == "/api/health-checks":
|
if path == "/api/health-checks":
|
||||||
self._send_health_check_list()
|
self._send_health_check_list()
|
||||||
return
|
return
|
||||||
@@ -131,6 +135,13 @@ class AppHandler(BaseHTTPRequestHandler):
|
|||||||
except (OSError, sqlite3.Error, ValueError):
|
except (OSError, sqlite3.Error, ValueError):
|
||||||
self._send_json(500, {"error": "Key status is unavailable"})
|
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):
|
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()))
|
||||||
|
|||||||
Reference in new issue
Block a user