(extra_config_settings={})
return app
Create a Flask application.
Create a Flask application.
Create a Flask application .
def create_app(extra_config_settings={}):
    """Create a Flask application.
    """
    # Instantiate Flask
    app = Flask(__name__)

    # Load common settings
    app.config.from_object('app.settings')
    # Load environment specific settings
    app.config.from_object('app.local_settings')
    # Load extra settings from extra_config_settings param
    app.config.update(extra_config_settings)

    # Setup Flask-SQLAlchemy
    db.init_app(app)

    # Setup Flask-Migrate
    migrate.init_app(app, db)

    # Setup Flask-Mail
    mail.init_app(app)

    # Setup WTForms CSRFProtect
    csrf_protect.init_app(app)

    # Register blueprints
    from .views import register_blueprints
    register_blueprints(app)

    # Define bootstrap_is_hidden_field for flask-bootstrap's bootstrap_wtf.html
    from wtforms.fields import HiddenField

    def is_hidden_field_filter(field):
        return isinstance(field, HiddenField)

    app.jinja_env.globals['bootstrap_is_hidden_field'] = is_hidden_field_filter

    # Setup an error-logger to send emails to app.config.ADMINS
    init_email_error_handler(app)

    # Setup Flask-User to handle user account related forms
    from .models.user_models import User
    from .views.main_views import user_profile_page

    # Setup Flask-User
    user_manager = UserManager(app, db, User)

    @app.context_processor
    def context_processor():
        return dict(user_manager=user_manager)

    return app
def create_app ( extra_config_settings = { } ) : # Instantiate Flask app = Flask ( __name__ ) # Load common settings app . config . from_object ( 'app.settings' ) # Load environment specific settings app . config . from_object ( 'app.local_settings' ) # Load extra settings from extra_config_settings param app . config . update ( extra_config_settings ) # Setup Flask-SQLAlchemy db . init_app ( app ) # Setup Flask-Migrate migrate . init_app ( app , db ) # Setup Flask-Mail mail . init_app ( app ) # Setup WTForms CSRFProtect csrf_protect . init_app ( app ) # Register blueprints from . views import register_blueprints register_blueprints ( app ) # Define bootstrap_is_hidden_field for flask-bootstrap's bootstrap_wtf.html from wtforms . fields import HiddenField def is_hidden_field_filter ( field ) : return isinstance ( field , HiddenField ) app . jinja_env . globals [ 'bootstrap_is_hidden_field' ] = is_hidden_field_filter # Setup an error-logger to send emails to app.config.ADMINS init_email_error_handler ( app ) # Setup Flask-User to handle user account related forms from . models . user_models import User from . views . main_views import user_profile_page # Setup Flask-User user_manager = UserManager ( app , db , User ) @ app . context_processor def context_processor ( ) : return dict ( user_manager = user_manager ) return app