|
@@ -4,12 +4,22 @@ from flask import Flask, render_template, request, redirect, url_for
|
|
|
import configparser
|
|
|
from gevent.pywsgi import WSGIServer
|
|
|
import socket
|
|
|
+import logging
|
|
|
|
|
|
config = configparser.ConfigParser()
|
|
|
config.read('settings.ini')
|
|
|
+application_settings = config['application']
|
|
|
smtp_settings = config['smtp']
|
|
|
http_settings = config['http']
|
|
|
|
|
|
+log = logging.getLogger('werkzeug')
|
|
|
+log.setLevel(logging.INFO)
|
|
|
+
|
|
|
+if application_settings['debug'].lower() == 'true':
|
|
|
+ debug = True
|
|
|
+else:
|
|
|
+ debug = False
|
|
|
+
|
|
|
|
|
|
def send_email(to, subject, body):
|
|
|
# Get settings from smtp_settings
|
|
@@ -53,8 +63,22 @@ def get_ip_address():
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
+ print("------------------------- Start up -----------------------------")
|
|
|
print("Starting HTTP Service on port %s..." % http_settings['port'])
|
|
|
- http_server = WSGIServer(('0.0.0.0', int(http_settings['port'])), app)
|
|
|
- print("HTTP Service Started!")
|
|
|
- print("Access the Dashboard on http://%s:%s" % (get_hostname(), http_settings['port']))
|
|
|
+
|
|
|
+ if debug is True:
|
|
|
+ print("Debug mode is enabled.")
|
|
|
+ http_server = WSGIServer(('0.0.0.0', int(http_settings['port'])), app)
|
|
|
+ else:
|
|
|
+ http_server = WSGIServer(('0.0.0.0', int(http_settings['port'])), app, log=log, error_log=log)
|
|
|
+ print("HTTP Service Started.")
|
|
|
+ print("--------------------- Application Details ---------------------")
|
|
|
+ print("Application started at %s" % datetime.datetime.now())
|
|
|
+ print("System IP Address: %s" % get_ip_address())
|
|
|
+ print("System Hostname: %s" % get_hostname())
|
|
|
+ print("Access the Dashboard using a web browser using any of the following:")
|
|
|
+ print("http://%s:%s or http://%s:%s" % (get_hostname(), http_settings['port'], get_ip_address(), http_settings['port']))
|
|
|
+ print("---------------------------------------------------------------")
|
|
|
+ print("To stop the application close this window.")
|
|
|
+ print("---------------------------------------------------------------")
|
|
|
http_server.serve_forever()
|