mqtt-dash/mqtt-dash

29 lines
633 B
Python
Executable File

#!/usr/bin/env python
import argparse
import os
import sys
from mqtt_dash.app import app
args = argparse.ArgumentParser()
args.add_argument('config', default='config.py', help='Configuration file')
options = args.parse_args()
app.secret_key = os.urandom(12)
app.config.from_pyfile(os.path.abspath(options.config))
missing_config_fields = False
for opt in ('URL', 'MQTT_BROKER', 'PAGE_TITLE', 'WIDGETS'):
if opt not in app.config:
print(f'Error: field {opt} missing in configuration')
missing_config_fields = True
if missing_config_fields:
sys.exit(1)
app.run(debug=False, host='0.0.0.0', port=4000)