added control page
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user