Exemple #1
0
def register_extensions(app, app_base=None):
    ''' Register the Flask extensions used '''

    jsg.JSGLUE_JS_PATH = '/{0}/jsglue.js'.format(app_base)
    jsglue.init_app(app)
    flags.init_app(app)
    configFeatures(app)
    cache.init_app(app, config=app.config)

    limiter.init_app(app)
    for handler in app.logger.handlers:
        limiter.logger.addHandler(handler)
    if app.config['RATELIMIT_ENABLED'] is False:
        limiter.enabled = False

    if app.config['USE_SENTRY']:
        sentry.init_app(app)

    # Initialize the Flask-Profiler ; see results at localhost:portnumber/app_base/flask-profiler
    if app.config['USE_PROFILER']:
        try:
            profiler.init_app(app)
        except Exception as e:
            pass

    # Initialize the Login Manager and JWT
    login_manager.init_app(app)
    login_manager.session_protection = "strong"
    jwt.init_app(app)
Exemple #2
0
def register_extensions(app, app_base=None):
    ''' Register the Flask extensions used '''

    jsg.JSGLUE_JS_PATH = '/{0}/jsglue.js'.format(app_base)
    jsglue.init_app(app)
    flags.init_app(app)
    configFeatures(app)
    cache.init_app(app, config=app.config)

    limiter.init_app(app)
    for handler in app.logger.handlers:
        limiter.logger.addHandler(handler)
    if app.config['RATELIMIT_ENABLED'] is False:
        limiter.enabled = False

    if app.config['USE_SENTRY'] is True:
        sentry.init_app(app)

    # Initialize the Flask-Profiler ; see results at localhost:portnumber/app_base/flask-profiler
    if app.config['USE_PROFILER']:
        try:
            profiler.init_app(app)
        except Exception as e:
            pass

    # Initialize the Login Manager and JWT
    login_manager.init_app(app)
    login_manager.session_protection = "strong"
    jwt.init_app(app)

    # intialize CORS
    cors.init_app(app,
                  supports_credentials=True,
                  expose_headers='Authorization',
                  origins=[
                      'https://*.sdss.org', 'https://*.sdss.utah.edu',
                      'http://localhost:*'
                  ])

    # initialize the Session
    session.init_app(app)

    # initialize Compress
    compress.init_app(app)