def events(): ttime = 0 while True: try: reload(common) content = int(common.readsettings("REFRESH")) if int(content) == 1: yield "data: reload\n\n" time.sleep(4) common.writesettings("REFRESH", "0") break elif ttime >= 3600: break else: yield "data: none\n\n" time.sleep(3) ttime += 3 except: break
def triggerrefresh(): if settings.triggerrefresh: import time def events(): ttime = 0 while True: try: reload(common) content = int(common.readsettings("REFRESH")) if int(content) == 1: yield "data: reload\n\n" time.sleep(4) common.writesettings("REFRESH", "0") break elif ttime >= 3600: break else: yield "data: none\n\n" time.sleep(3) ttime += 3 except: break if settings.running_with_iis: reload(common) content = int(common.readsettings("REFRESH")) if int(content) == 1: out = "data: reload\n\n" time.sleep(4) common.writesettings("REFRESH", "0") else: out = "data: none\n\n" return Response(out, content_type="text/event-stream") else: return Response(events(), content_type='text/event-stream') else: return render_template('error/400.html'), 400
from views.backend import backend app.register_blueprint(frontend) app.register_blueprint(backend) import logging from logging.handlers import RotatingFileHandler file_handler = RotatingFileHandler(os.path.abspath(os.path.dirname(__file__)) + '/monitornjus.log', maxBytes=10000, backupCount=1) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if common.readsettings("APPKEY") == "None": import binascii key = os.urandom(24) hexkey = binascii.hexlify(os.urandom(32)).decode() common.writesettings("APPKEY", hexkey) app.secret_key = hexkey else: app.secret_key = common.readsettings("APPKEY") if settings.SSL: app.config["SSL"] = True if settings.running_with_iis == True: from werkzeug.wsgi import DispatcherMiddleware app.wsgi_app = DispatcherMiddleware( app.wsgi_app, {settings.iis_virtual_path: app.wsgi_app})
from views.frontend import frontend from views.backend import backend app.register_blueprint(frontend) app.register_blueprint(backend) import logging from logging.handlers import RotatingFileHandler file_handler = RotatingFileHandler(os.path.abspath(os.path.dirname( __file__)) + '/monitornjus.log', maxBytes=10000, backupCount=1) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if common.readsettings("APPKEY") == "None": import binascii key = os.urandom(24) hexkey = binascii.hexlify(os.urandom(32)).decode() common.writesettings("APPKEY", hexkey) app.secret_key = hexkey else: app.secret_key = common.readsettings("APPKEY") if settings.SSL: app.config["SSL"] = True if settings.running_with_iis == True: from werkzeug.wsgi import DispatcherMiddleware app.wsgi_app = DispatcherMiddleware( app.wsgi_app, {settings.iis_virtual_path: app.wsgi_app})