refactor: Externalize host configuration to hosts.json

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-01-14 10:24:55 -07:00
parent 8ac59ea7d5
commit 476342d654
2 changed files with 18 additions and 11 deletions

View File

@@ -0,0 +1,11 @@
{
"http": [
"tanner.vc",
"forum.protospace.ca",
"protospace.ca",
"my.protospace.ca"
],
"mqtt": [
"webhost.protospace.ca"
]
}

18
main.py
View File

@@ -8,20 +8,16 @@ import asyncio
import aiohttp
import aiomqtt
import ssl
import json
from datetime import datetime, timedelta
HOSTS = {
'http': [
'tanner.vc',
'forum.protospace.ca',
'protospace.ca',
'my.protospace.ca',
],
'mqtt': [
'webhost.protospace.ca',
],
}
try:
with open('hosts.json', 'r') as f:
HOSTS = json.load(f)
except FileNotFoundError:
logging.error("hosts.json not found. Please copy hosts.json.example to hosts.json and configure it.")
exit(1)
def alert_tanner(msg):