2019-10-31 17:24:26 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2019-10-31 20:59:07 +01:00
|
|
|
import argparse
|
2019-10-31 17:24:26 +01:00
|
|
|
import os
|
2019-10-31 20:59:07 +01:00
|
|
|
import sys
|
2019-10-31 17:24:26 +01:00
|
|
|
|
|
|
|
from mqtt_dash.app import app
|
|
|
|
|
2019-10-31 20:59:07 +01:00
|
|
|
args = argparse.ArgumentParser()
|
|
|
|
|
|
|
|
args.add_argument('config', default='config.py', help='Configuration file')
|
|
|
|
|
|
|
|
options = args.parse_args()
|
2019-10-31 17:24:26 +01:00
|
|
|
|
|
|
|
app.secret_key = os.urandom(12)
|
2019-10-31 20:59:07 +01:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2019-10-31 17:24:26 +01:00
|
|
|
app.run(debug=False, host='0.0.0.0', port=4000)
|