fulltext/factory.py
def create_web_app(for_worker: bool = False) -> Flask:
    """Initialize an instance of the web application."""
    app = Flask('fulltext')
    app.config.from_pyfile('config.py')
    app.url_map.converters['source'] = SubmissionSourceConverter

    if app.config['LOGLEVEL'] < 40:
        # Make sure that boto doesn't spam the logs when we're in debug mode.
        pylogging.getLogger('boto').setLevel(pylogging.ERROR)
        pylogging.getLogger('boto3').setLevel(pylogging.ERROR)
        pylogging.getLogger('botocore').setLevel(pylogging.ERROR)

    Base(app)
    Auth(app)
    app.register_blueprint(routes.blueprint)
    store.Storage.current_session().init_app(app)
    legacy.CanonicalPDF.init_app(app)
    preview.PreviewService.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['WAIT_FOR_SERVICES']:
        time.sleep(app.config['WAIT_ON_STARTUP'])
        with app.app_context():
            wait_for(store.Storage.current_session())
            if app.config['CANONICAL_AWAIT']:
                wait_for(legacy.CanonicalPDF.current_session())
            if app.config['PREVIEW_AWAIT']:
                wait_for(preview.PreviewService.current_session())
            if for_worker:
                wait_for(extractor.do_extraction)
            else:
                wait_for(extract, await_result=True)    # type: ignore
        logger.info('All upstream services are available; ready to start')

    register_error_handlers(app)
    app.celery_app = extract.get_or_create_worker_app(app)
    return app
Initialize an instance of the web application.
Initialize an instance of the web application.
Initialize an instance of the web application .
def create_web_app(for_worker: bool = False) -> Flask:
    app = Flask('fulltext')
    app.config.from_pyfile('config.py')
    app.url_map.converters['source'] = SubmissionSourceConverter
    if app.config['LOGLEVEL'] < 40:
        pylogging.getLogger('boto').setLevel(pylogging.ERROR)
        pylogging.getLogger('boto3').setLevel(pylogging.ERROR)
        pylogging.getLogger('botocore').setLevel(pylogging.ERROR)
    Base(app)
    Auth(app)
    app.register_blueprint(routes.blueprint)
    store.Storage.current_session().init_app(app)
    legacy.CanonicalPDF.init_app(app)
    preview.PreviewService.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['WAIT_FOR_SERVICES']:
        time.sleep(app.config['WAIT_ON_STARTUP'])
        with app.app_context():
            wait_for(store.Storage.current_session())
            if app.config['CANONICAL_AWAIT']:
                wait_for(legacy.CanonicalPDF.current_session())
            if app.config['PREVIEW_AWAIT']:
                wait_for(preview.PreviewService.current_session())
            if for_worker:
                wait_for(extractor.do_extraction)
            else:
                wait_for(extract, await_result=True)    
        logger.info('All upstream services are available; ready to start')
    register_error_handlers(app)
    app.celery_app = extract.get_or_create_worker_app(app)
    return app
def create_web_app ( for_worker : bool = False ) -> Flask : app = Flask ( 'fulltext' ) app . config . from_pyfile ( 'config.py' ) app . url_map . converters [ 'source' ] = SubmissionSourceConverter if app . config [ 'LOGLEVEL' ] < 40 : pylogging . getLogger ( 'boto' ) . setLevel ( pylogging . ERROR ) pylogging . getLogger ( 'boto3' ) . setLevel ( pylogging . ERROR ) pylogging . getLogger ( 'botocore' ) . setLevel ( pylogging . ERROR ) Base ( app ) Auth ( app ) app . register_blueprint ( routes . blueprint ) store . Storage . current_session ( ) . init_app ( app ) legacy . CanonicalPDF . init_app ( app ) preview . PreviewService . 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 [ 'WAIT_FOR_SERVICES' ] : time . sleep ( app . config [ 'WAIT_ON_STARTUP' ] ) with app . app_context ( ) : wait_for ( store . Storage . current_session ( ) ) if app . config [ 'CANONICAL_AWAIT' ] : wait_for ( legacy . CanonicalPDF . current_session ( ) ) if app . config [ 'PREVIEW_AWAIT' ] : wait_for ( preview . PreviewService . current_session ( ) ) if for_worker : wait_for ( extractor . do_extraction ) else : wait_for ( extract , await_result = True ) logger . info ( 'All upstream services are available; ready to start' ) register_error_handlers ( app ) app . celery_app = extract . get_or_create_worker_app ( app ) return app
Initialize an instance of the web application.
Initialize an instance of the web application .
"""Initialize an instance of the web application.""" # Make sure that boto doesn't spam the logs when we're in debug mode. # type: ignore
for_worker
bool