def register_web_server(manager): """Registers Web Server and loads API (always) and WebUi via config""" global web_server, config_hash if not manager.is_daemon: return config = manager.config.get('web_server') if get_config_hash(config) == config_hash: log.debug('web server config has\'nt changed') return config_hash = get_config_hash(config) web_server_config = prepare_config(config) # Removes any existing web server instances if exists stop_server(manager) if not web_server_config: return log.info("Running web server at IP %s:%s", web_server_config['bind'], web_server_config['port']) # Register API api_app.secret_key = get_secret() log.info("Initiating API") register_app('/api', api_app) # Register WebUI if web_server_config.get('web_ui'): log.info('Registering WebUI') register_web_ui(manager) web_server = setup_server(web_server_config)
def register_web_server(manager): """ Registers Web Server and loads API (always) and WebUi via config """ web_server_config = manager.config.get('web_server') web_server_config = prepare_config(web_server_config) if not web_server_config: log.debug( "Not starting web server as it's disabled or not set in the config" ) return log.info("Running web server at IP %s:%s", web_server_config['bind'], web_server_config['port']) # Register API api_app.secret_key = get_secret() log.info("Initiating API") register_app('/api', api_app) # Register WebUI if web_server_config.get('web_ui'): log.info('Registering WebUI') register_web_ui(manager) setup_server(web_server_config)
def register_api(mgr): global api_config api_config = mgr.config.get('api') app.secret_key = get_secret() if api_config: register_app('/api', app)