def create_app(config_name): """Creat app and return""" # Flask app app = Flask(__name__) # pylint: disable=invalid-name from {{cookiecutter.module_name}}.config import config app.config.from_object(config[config_name]) config[config_name].init_app(app) # set up extensions # set up extensions db.init_app(app) mg.init_app(app, db) ma.init_app(app) # Setup the Flask-JWT-Extended extension and CORS JWTManager(app) CORS(app, resources={r"/{{ cookiecutter.api_prefix}}/*": {"origins": "*"}}) # Add logger if config_name == 'development' or config_name == 'default': app.logger.setLevel(logging.INFO) # pylint: disable=no-member else: app.logger.setLevel(logging.ERROR) # pylint: disable=no-member # API blueprints, imported after OS.environ from {{cookiecutter.module_name}}.apis.public import public_api app.register_blueprint(public_api) from {{cookiecutter.module_name}}.apis.private import private_api app.register_blueprint(private_api) from {{cookiecutter.module_name}}.apis.test import test_api app.register_blueprint(test_api) return app
def create_app(env_name): """ Create app """ # app initiliazation app = Flask(__name__) CORS(app) app.config.from_object(app_config[env_name]) # initializing bcrypt and db bcrypt.init_app(app) db.init_app(app) ma.init_app(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run() # Route api = Api(app) # user endpoint api.add_resource(Login, '/auth/login') api.add_resource(Register, '/auth/register') return app
def register_extensions(app): db.init_app(app) migrate.init_app(app, db) ma.init_app(app) <%= unless bare do %> bcrypt.init_app(app) jwt.init_app(app) <% end %>
def configure_extensions(app, cli): """configure flask extensions """ db.init_app(app) jwt.init_app(app) ma.init_app(app) if cli is True: migrate.init_app(app, db)
def register_extensions(app): """ Register Flask extensions. """ bcrypt.init_app(app) cache.init_app(app) csrf_protect.init_app(app) login_manager.init_app(app) debug_toolbar.init_app(app) migrate.init_app(app, db) # webpack.init_app(app) jwt.init_app(app) # If db is SQLAlchemy instance, # Flask-SQLAlchemy must be initialized before Flask-Marshmallow db.init_app(app) ma.init_app(app) mail.init_app(app) rest_api.init_app(app) celery.init_app(app)