Esempio n. 1
0
def create_app(interface_app=False):
    if not interface_app:
        connexion_app = _app = connexion.App(__name__,
                                             specification_dir='../api/',
                                             options={'swagger_ui': False})
        _app = connexion_app.app
    else:
        _app = Flask(__name__)

    _app.jinja_loader = FileSystemLoader(['walkoff/templates'])
    _app.config.from_object(walkoff.config.Config)

    try:
        db.init_app(_app)
    except Exception as e:
        logger.error(
            "Error initializing walkoff database. Please make sure all settings are properly configured in the"
            "config file, and that all necessary environment variables are set correctly."
            "Error message: {}".format(str(e)))
        os._exit(1)

    if not interface_app:
        jwt.init_app(_app)
        connexion_app.add_api('composed_api.yaml')
        _app.running_context = context.Context()
        register_blueprints(_app, walkoff.config.Config.SEPARATE_INTERFACES)
        register_swagger_blueprint(_app)
    else:
        _app.running_context = context.Context(executor=False)
        __register_all_app_blueprints(_app)

    add_health_check(_app)

    return _app
Esempio n. 2
0
def create_app():
    import walkoff.config.config
    connexion_app = connexion.App(__name__, specification_dir='../api/')
    _app = connexion_app.app
    _app.jinja_loader = FileSystemLoader(['walkoff/templates'])
    _app.config.update(
        # CHANGE SECRET KEY AND SECURITY PASSWORD SALT!!!
        SECRET_KEY=walkoff.config.config.secret_key,
        SQLALCHEMY_DATABASE_URI=format_db_path(
            walkoff.config.config.walkoff_db_type,
            os.path.abspath(paths.db_path)),
        SECURITY_PASSWORD_HASH='pbkdf2_sha512',
        SECURITY_TRACKABLE=False,
        SECURITY_PASSWORD_SALT='something_super_secret_change_in_production',
        SECURITY_POST_LOGIN_VIEW='/',
        WTF_CSRF_ENABLED=False,
        JWT_BLACKLIST_ENABLED=True,
        JWT_BLACKLIST_TOKEN_CHECKS=['refresh'],
        JWT_TOKEN_LOCATION='headers',
        SQLALCHEMY_TRACK_MODIFICATIONS=False)

    db.init_app(_app)
    jwt.init_app(_app)
    connexion_app.add_api('composed_api.yaml')

    walkoff.config.config.initialize()
    register_blueprints(_app)

    import walkoff.server.workflowresults  # Don't delete this import
    import walkoff.messaging.utils  # Don't delete this import
    return _app
Esempio n. 3
0
def create_app(app_config):
    connexion_app = connexion.App(__name__, specification_dir='../api/')
    _app = connexion_app.app
    _app.jinja_loader = FileSystemLoader(['walkoff/templates'])
    _app.config.from_object(app_config)

    db.init_app(_app)
    jwt.init_app(_app)
    connexion_app.add_api('composed_api.yaml')

    _app.running_context = context.Context(walkoff.config.Config)
    register_blueprints(_app)

    return _app