Example #1
0
def init_memorious():
    if settings.DEBUG:
        configure_logging(level=logging.DEBUG)
    else:
        configure_logging(level=logging.INFO)
    for func in get_extensions("memorious.plugins"):
        func()
Example #2
0
def create_app(config={}):
    configure_logging(level=logging.DEBUG)
    app = Flask("aleph")
    app.config.from_object(settings)
    app.config.update(config)

    if "postgres" not in settings.DATABASE_URI:
        raise RuntimeError("aleph database must be PostgreSQL!")

    app.config.update({
        "SQLALCHEMY_DATABASE_URI": settings.DATABASE_URI,
        "FLASK_SKIP_DOTENV": True,
        "FLASK_DEBUG": settings.DEBUG,
        "BABEL_DOMAIN": "aleph",
        "PROFILE": settings.PROFILE,
    })

    if settings.PROFILE:
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])

    migrate.init_app(app, db, directory=settings.ALEMBIC_DIR)
    configure_oauth(app, cache=get_cache())
    mail.init_app(app)
    db.init_app(app)
    babel.init_app(app)
    CORS(
        app,
        resources=r"/api/*",
        origins=settings.CORS_ORIGINS,
        supports_credentials=True,
    )
    feature_policy = {
        "accelerometer": NONE,
        "camera": NONE,
        "geolocation": NONE,
        "gyroscope": NONE,
        "magnetometer": NONE,
        "microphone": NONE,
        "payment": NONE,
        "usb": NONE,
    }
    talisman.init_app(
        app,
        force_https=settings.FORCE_HTTPS,
        strict_transport_security=settings.FORCE_HTTPS,
        feature_policy=feature_policy,
        content_security_policy=settings.CONTENT_POLICY,
    )

    from aleph.views import mount_app_blueprints

    mount_app_blueprints(app)

    # This executes all registered init-time plugins so that other
    # applications can register their behaviour.
    for plugin in get_extensions("aleph.init"):
        plugin(app=app)

    return app
Example #3
0
def create_app(config={}):
    configure_logging()
    app = Flask('aleph')
    app.config.from_object(settings)
    app.config.update(config)

    if 'postgres' not in settings.DATABASE_URI:
        raise RuntimeError("aleph database must be PostgreSQL!")

    app.config.update({
        'SQLALCHEMY_DATABASE_URI': settings.DATABASE_URI,
        'FLASK_SKIP_DOTENV': True,
        'FLASK_DEBUG': settings.DEBUG,
        'BABEL_DOMAIN': 'aleph',
    })

    migrate.init_app(app, db, directory=settings.ALEMBIC_DIR)
    configure_oauth(app, cache=get_cache())
    mail.init_app(app)
    db.init_app(app)
    babel.init_app(app)
    CORS(app,
         resources=r'/api/*',
         origins=settings.CORS_ORIGINS,
         supports_credentials=True)
    feature_policy = {
        'accelerometer': NONE,
        'camera': NONE,
        'geolocation': NONE,
        'gyroscope': NONE,
        'magnetometer': NONE,
        'microphone': NONE,
        'payment': NONE,
        'usb': NONE
    }
    talisman.init_app(app,
                      force_https=settings.FORCE_HTTPS,
                      strict_transport_security=settings.FORCE_HTTPS,
                      feature_policy=feature_policy,
                      content_security_policy=settings.CONTENT_POLICY)

    from aleph.views import mount_app_blueprints
    mount_app_blueprints(app)

    # Monkey-patch followthemoney
    # from aleph.logic.names import name_frequency
    # registry.name._specificity = name_frequency

    # This executes all registered init-time plugins so that other
    # applications can register their behaviour.
    for plugin in get_extensions('aleph.init'):
        plugin(app=app)

    return app
Example #4
0
def cli():
    configure_logging(level=logging.DEBUG)
Example #5
0
def cli():
    configure_logging()