Exemple #1
0
def create_app(app_config='DEFAULT'):
    app = Flask(__name__, instance_relative_config=True)

    # Load config
    app.config.from_object(config[app_config])

    # Load config from instance folder.
    app.config.from_pyfile('config.py', silent=True)

    # Load the file specified by the APP_CONFIG_FILE env variable
    app.config.from_envvar('APP_CONFIG_FILE', silent=True)

    # Load database
    db.init_app(app)

    # Register blueprints
    app.register_blueprint(web, url_prefix='/', static_folder='static')

    return app
Exemple #2
0
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(Config)
    from flaskapp.models import db
    db.init_app(app)
    bcrypt.init_app(app)
    login.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)

    from flaskapp.users.routes import users
    from flaskapp.posts.routes import posts
    from flaskapp.main.routes import main
    from flaskapp.errors.handlers import errors
    app.register_blueprint(users)
    app.register_blueprint(posts)
    app.register_blueprint(main)
    app.register_blueprint(errors)

    return app
Exemple #3
0
def create_db(app_config='DEFAULT'):
    app = create_app(app_config=app_config)
    db.init_app(app)
    with app.test_request_context():
        from flaskapp.models import Project
        db.create_all()