Ejemplo n.º 1
0
def create_app(settings=settings):
    app = Flask(__name__)
    app.config.from_object(settings)
    app.jinja_env.add_extension(HamlPyExtension)
    app.jinja_env.hamlish_mode = 'indented'
    # initialize extensions and assets
    init_extensions(application=app)
    init_assets(application=app)
    # register blueprints
    app.register_blueprint(dummy.dummy)
    return app
Ejemplo n.º 2
0
def create_app(config_filename=None, config_options_name=None):
    """
    Creates and returns the flask application object.

    :param config_filename: Filename with application configuration parameters
    :param config_options: Python module with the class options for configuring the application.
    :return: wsgi Flask application
    """
    app = Flask(__name__)

    # Todo: Move to a function or separate module for cleaner segregation of duties
    app.register_blueprint(compute)
    app.register_blueprint(default)
    init_extensions(app)

    default_configuration = base_config.get_configuration(config_options_name)
    print('Using {0} configuration'.format(default_configuration.__name__))
    app.config.from_object(default_configuration)
    if config_filename is not None:
        # Override base configuration parameters with more specific ones from a configuration file.
        app.config.from_pyfile(config_filename)
    return app
Ejemplo n.º 3
0
Archivo: app.py Proyecto: hoang89/fbone
def configure_extensions(app):
    # flask-babel
    babel = Babel(app)

    @babel.localeselector
    def get_locale():
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        return request.accept_languages.best_match(accept_languages)

    # flask-sqlalchemy
    db.init_app(app)

    # flask-mail
    mail.init_app(app)

    #mongo db
    mongo.init_app(app)

    # flask-cache
    cache.init_app(app)

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(id)
    login_manager.init_app(app)

    # flask-openid
    oid.init_app(app)

    # init debug toolbar
    toolbar = DebugToolbarExtension(app)

    init_extensions(app)