def create_web_app() -> Flask: """Initialize and configure the accounts application.""" app = Flask('registry') app.config.from_pyfile('config.py') # app.register_blueprint(ui.blueprint) datastore.init_app(app) SessionStore.init_app(app) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) # Handless sessions and authn/z. oauth2.init_app(app) app.register_blueprint(blueprint) middleware = [AuthMiddleware] if app.config['VAULT_ENABLED']: middleware.insert(0, vault.middleware.VaultMiddleware) wrap(app, middleware) if app.config['VAULT_ENABLED']: app.middlewares['VaultMiddleware'].update_secrets({}) app.jinja_env.filters['scope_label'] = filters.scope_label if app.config['CREATE_DB']: with app.app_context(): datastore.create_all() register_error_handlers(app) return app
def create_web_app() -> Flask: """Initialize and configure the accounts application.""" app = Flask('accounts') app.config.from_pyfile('config.py') SessionStore.init_app(app) legacy.init_app(app) users.init_app(app) app.register_blueprint(ui.blueprint) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) # Handless sessions and authn/z. s3.init_app(app) middleware = [auth.middleware.AuthMiddleware] if app.config['VAULT_ENABLED']: middleware.insert(0, vault.middleware.VaultMiddleware) wrap(app, middleware) if app.config['VAULT_ENABLED']: app.middlewares['VaultMiddleware'].update_secrets({}) if app.config['CREATE_DB']: with app.app_context(): legacy.create_all() users.create_all() return app
def create_classic_api_web_app() -> Flask: """Initialize an instance of the search frontend UI web application.""" logging.getLogger("boto").setLevel(logging.ERROR) logging.getLogger("boto3").setLevel(logging.ERROR) logging.getLogger("botocore").setLevel(logging.ERROR) app = Flask("search") app.json_encoder = ISO8601JSONEncoder app.config.from_pyfile("config.py") # type: ignore index.SearchSession.init_app(app) Base(app) auth.Auth(app) app.register_blueprint(classic_api.blueprint) wrap( app, [request_logs.ClassicLogsMiddleware, auth.middleware.AuthMiddleware], ) for error, handler in classic_api.exceptions.get_handlers(): app.errorhandler(error)(handler) return app
def create_api_app() -> Flask: """Create a new API application.""" app = Flask('funding') app.config.from_pyfile('config.py') Base(app) auth.Auth(app) app.register_blueprint(routes.api.blueprint) wrap(app, [auth.middleware.AuthMiddleware]) register_error_handlers(app) return app
def _create_base_app() -> Flask: app = Flask('zero') app.config.from_pyfile('config.py') app.json_encoder = ISO8601JSONEncoder baz.BazService.init_app(app) things.init_app(app) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) # Sets up authn/z machinery. wrap(app, [auth.middleware.AuthMiddleware]) return app
def create_web_app() -> Flask: """Initialize and configure the accounts application.""" app = Flask('accounts') app.config.from_pyfile('config.py') sessions.init_app(app) legacy.init_app(app) users.init_app(app) app.register_blueprint(ui.blueprint) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) # Handless sessions and authn/z. wrap(app, [auth.middleware.AuthMiddleware]) return app
def create_app() -> Flask: """Create an instance of the compiler service app.""" from . import celeryconfig app = Flask(__name__) filemanager.FileManager.init_app(app) store.Store.init_app(app) app.config.from_pyfile('config.py') celery_app.config_from_object(celeryconfig) Base(app) auth.Auth(app) app.register_blueprint(routes.blueprint) register_error_handlers(app) middleware = [auth.middleware.AuthMiddleware] if app.config['VAULT_ENABLED']: middleware.insert(0, vault.middleware.VaultMiddleware) wrap(app, middleware) if app.config['VAULT_ENABLED']: app.middlewares['VaultMiddleware'].update_secrets({}) # Leaving this here for future performance tuning. - Erick # # app.config['PROFILE'] = True # app.config['DEBUG'] = True # app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[100], # sort_by=('cumtime', )) # if app.config['WAIT_FOR_SERVICES']: with app.app_context(): # type: ignore logger.info('initialize and wait for upstream services') # Adding a wait here can help keep boto3 from getting stuck if # we are starting localstack at the same time. This can probably # just be 0 (default) in production. time.sleep(app.config['WAIT_ON_STARTUP']) filemanager_service = filemanager.FileManager.current_session() store_service = store.Store.current_session() store_service.initialize() wait_for(filemanager_service) if app.config['WAIT_FOR_WORKER']: wait_for(compiler, await_result=True) # type: ignore logger.info('All upstream services are available; ready to start') return app
def create_web_app() -> Flask: """Initialize an instance of the extractor backend service.""" app = Flask('metadata') classic.init_app(app) app.config.from_pyfile('config.py') Base(app) auth.Auth(app) app.register_blueprint(routes.blueprint) app.errorhandler(Forbidden)(jsonify_exception) app.errorhandler(NotFound)(jsonify_exception) app.errorhandler(BadRequest)(jsonify_exception) app.errorhandler(Unauthorized)(jsonify_exception) wrap(app, [auth.middleware.AuthMiddleware]) return app
def create_web_app() -> Flask: """Initialize and configure the accounts application.""" app = Flask('registry') app.config.from_pyfile('config.py') # app.register_blueprint(ui.blueprint) datastore.init_app(app) sessions.init_app(app) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) # Handless sessions and authn/z. oauth2.init_app(app) app.register_blueprint(blueprint) wrap(app, [auth.middleware.AuthMiddleware]) app.jinja_env.filters['scope_label'] = filters.scope_label datastore.create_all() return app
def create_ui_web_app() -> Flask: """Initialize an instance of the search frontend UI web application.""" app = Flask('submit', static_folder='static', template_folder='templates') app.url_map.strict_slashes = False app.config.from_pyfile('config.py') Base(app) auth.Auth(app) app.register_blueprint(ui.ui) middleware = [ request_logs.ClassicLogsMiddleware, auth.middleware.AuthMiddleware ] if app.config['VAULT_ENABLED']: middleware.insert(0, vault.middleware.VaultMiddleware) wrap(app, middleware) # Make sure that we have all of the secrets that we need to run. if app.config['VAULT_ENABLED']: app.middlewares['VaultMiddleware'].update_secrets({}) for filter_name, filter_func in filters.get_filters(): app.jinja_env.filters[filter_name] = filter_func # Initialize services. init_app(app) Compiler.init_app(app) FileManager.init_app(app) if app.config['WAIT_FOR_SERVICES']: time.sleep(app.config['WAIT_ON_STARTUP']) with app.app_context(): wait_for(FileManager.current_session(), timeout=app.config['FILEMANAGER_STATUS_TIMEOUT']) wait_for(Compiler.current_session(), timeout=app.config['COMPILER_STATUS_TIMEOUT']) logger.info('All upstream services are available; ready to start') return app
def create_api_web_app() -> Flask: """Initialize an instance of the search frontend UI web application.""" logging.getLogger('boto').setLevel(logging.ERROR) logging.getLogger('boto3').setLevel(logging.ERROR) logging.getLogger('botocore').setLevel(logging.ERROR) app = Flask('search') app.json_encoder = ISO8601JSONEncoder app.config.from_pyfile('config.py') index.init_app(app) Base(app) auth.Auth(app) app.register_blueprint(api.blueprint) wrap(app, [request_logs.ClassicLogsMiddleware, auth.middleware.AuthMiddleware]) for error, handler in api.exceptions.get_handlers(): app.errorhandler(error)(handler) return app
def create_web_app() -> Flask: """Initialize and configure the filemanager application.""" app = Flask('filemanager') app.config.from_pyfile('config.py') app.json_encoder = ISO8601JSONEncoder # Initialize file management app uploads.init_app(app) Base(app) # Gives us access to the base UI templates and resources. auth.Auth(app) app.register_blueprint(upload_api.blueprint) middleware = [auth.middleware.AuthMiddleware] if app.config['VAULT_ENABLED']: middleware.insert(0, vault.middleware.VaultMiddleware) wrap(app, middleware) if app.config['VAULT_ENABLED']: app.middlewares['VaultMiddleware'].update_secrets({}) register_error_handlers(app) return app