added control page

This commit is contained in:
2026-07-09 19:40:33 +02:00
parent 19fec18cf7
commit 149ef202e3
9 changed files with 263 additions and 11 deletions

View File

@@ -1,9 +1,24 @@
import subprocess
import json
import sys
import traceback
from db import init_db, insert_result
from db import init_db, insert_result, init_settings_db, get_setting
from config import SPEEDTEST_ENABLED
def speedtests_enabled() -> bool:
# The control page writes the live toggle to the settings table;
# the env var only covers the case where the toggle was never used.
init_settings_db()
value = get_setting("speedtest_enabled")
if value is None:
return SPEEDTEST_ENABLED
return value == "1"
def run_test_and_save():
if not speedtests_enabled():
print("Speedtests are disabled, skipping run")
sys.exit(0)
print("==== Running Ookla Speedtest ====")
init_db()