Пример #1
0
def register_exetensions(app):
    mail.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)
    assets.init_app(app)
    return None
Пример #2
0
def register_extensions(app):
    db.init_app(app)
    login_manager.init_app(app)
    assets.init_app(app)
    toolbar = DebugToolbarExtension(app)
    cache.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #3
0
def register_extensions(app):
    assets.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #4
0
def register_extensions(app):
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #5
0
def register_extensions(app):
    db.init_app(app)
    dbm.init_app(app)
    login_manager.init_app(app)
    assets.init_app(app)
    if app.config['DEBUG_TB_ENABLED']:
        DebugToolbarExtension(app)
    cache.init_app(app)
    migrate.init_app(app, db)
    return None
def configure_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #7
0
def register_extensions(app):
    db.init_app(app)
    login_manager.init_app(app)
    assets.init_app(app)
    assets.app = app
    assets.url = app.static_url_path
    toolbar = DebugToolbarExtension(app)
    cache.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #8
0
def register_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #9
0
def register_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    debug_toolbar.init_app(app)
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security.init_app(app, user_datastore)
    migrate.init_app(app, db)
    return None
Пример #10
0
def register_extensions(app):
    """Register Flask extensions."""
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Пример #11
0
def create_app():
    app = Flask(__name__)

    app.config.from_object('hab.config')
    app.config.update({
        k: auto_convert(os.environ[k])
        for k in app.config
        if k in os.environ})

    assets.init_app(app)

    app.register_blueprint(blueprint.bp)
    return app
Пример #12
0
def get_app(config=None):

    app_dir = os.path.dirname(os.path.realpath(__file__))
    logging.basicConfig(
        filename= app_dir + '/../log/app.log',
        format='%(asctime)s - %(name)s - %(levelname)s: %(message)s', 
        datefmt='%m/%d/%Y %I:%M:%S %p',
        level=logging.DEBUG)
    logging.info('TandemApi Started')

    if config is None:
        config = {}

    for key in dir(settings):
        if key.isupper():
            config.setdefault(key, getattr(settings, key))

    def encrypt_pass(documents):
        for document in documents:
            salt = app.config.get('BCRYPT_GENSALT_WORK_FACTOR', 12)
            password_hash = bcrypt.hashpw(document['password'].encode('UTF-8'), bcrypt.gensalt(salt)) 
            document['password'] = password_hash.decode('UTF-8')

    def add_points(documents):
        users = app.data.driver.db['users']
        for document in documents:
            lookup = {
                '_id': document['submitted_by']
            }
            user = users.find_one(lookup)
            if user:
                user['points'] = int(user.get('points', 0) + 10)
                users.save(user)
            
    app = Eve(auth=TandemTokenAuth, settings=config)
    cors = CORS(app)

    # on every new user insert
    app.on_insert_users += encrypt_pass

    # on every new audio insert
    app.on_insert_audio += add_points

    auth.init_app(app)
    mobile.init_app(app)
    assets.init_app(app)
 
    return app
Пример #13
0
def create_app(debug=False):
    """Returns the ankit.io front-end application instance."""

    app = factory.create_app(__name__, __path__, debug=debug)

    # Init assets
    assets.init_app(app)

    # Setup front-end logging.
    @app.before_request
    def log_request():
        log.debug('Front-end request from %s to location %s' % (request.remote_addr, request.path))

    # Register error handlers for exceptional cases.
    app.errorhandler(404)(_on_404)
    app.errorhandler(500)(_on_500)

    return app
Пример #14
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    app.config.from_pyfile(path.join(app.instance_path, config[config_name].CUSTOM_CONFIG), silent=True)
    config[config_name].init_app(app)

    mail.init_app(app)
    socketio.init_app(app)
    babel.init_app(app)
    login_manager.init_app(app)
    db.init_app(app)
    admin.init_app(app)

    import assets

    assets.init_app(app)

    app.json_encoder = CustomJSONEncoder

    from .dashboard import dashboard as dashboard_blueprint

    app.register_blueprint(dashboard_blueprint)

    from .auth import auth as auth_blueprint

    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .admin import adminbp as adminbp_blueprint

    app.register_blueprint(adminbp_blueprint, url_prefix='/admin')

    from flask.ext.login import current_user

    @babel.localeselector
    def get_locale():
        if current_user is not None and hasattr(current_user, 'locale') and current_user.locale is not None:
            locale = current_user.locale
        else:
            locale = app.config['BABEL_DEFAULT_LOCALE']
            # or select best match:
            # request.accept_languages.best_match(current_app.config['LANGUAGES'].keys())
        return locale

    return app
Пример #15
0
def register_extensions(app):
    assets.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    migrate.init_app(app, Base)
    return None
Пример #16
0
# coding=utf-8
from flask import Flask, render_template

import assets


app = Flask(__name__)
assets.init_app(app)


@app.route('/')
def hello():
    return render_template('index.html')


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=9000, debug=app.debug)