예제 #1
0
def create_app(config, env="prod"):
  """
  Application factory
    config - the config object
    env - name of environment to load
  """

  app = Flask(__name__)

  app.config.from_object(config)
  app.config['ENV'] = env

  # Flask cache init
  cache.init_app(app)

  # Markdown
  md = Markdown(app)

  # initialize the debug tool bar
  debug_toolbar.init_app(app)

  # initialize SQLAlchemy
  db.init_app(app)

  login_manager.init_app(app)

  # register our blueprints
  app.register_blueprint(main)
  app.register_blueprint(user, url_prefix='/user')
  app.register_blueprint(api, url_prefix='/api')

  return app
예제 #2
0
def register_extensions(app):
    db.init_app(app)
    bootstrap.init_app(app)
    moment.init_app(app)
    login_manager.init_app(app)
    ckeditor.init_app(app)
    csrf.init_app(app)
예제 #3
0
def register_extensions(app):
    db.init_app(app)
    migrate.init_app(app, db, compare_type=True)
    csrf.init_app(app)
    admin.init_app(app)

    api.plugins = [
        EventPlugin(),
        PermissionPlugin(),
        ApiSpecPlugin(app=app,
                      tags={
                          'Tag': 'Tag API',
                          'User': '******',
                          'Author': 'Author API',
                          'Article': 'Article API',
                      }),
    ]
    api.init_app(app)

    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(int(user_id))
예제 #4
0
def create_app(app_config):
    """Initialize the core application."""
    app = Flask(__name__, instance_relative_config=False)
    app.config.from_object(app_config)

    # Initialize plugins
    compress.init_app(app)
    login_manager.init_app(app)
    db.init_app(app)

    with app.app_context():
        from blog.views import app_blueprint, error400, error404, error500

        # Register blueprints
        app.register_blueprint(app_blueprint)

        # Register error pages
        app.register_error_handler(400, error400)
        app.register_error_handler(404, error404)
        app.register_error_handler(500, error500)

        # Create database tables for our data models
        db.create_all()

        return app
예제 #5
0
def register_extensions(app):
    bootstrap.init_app(app)  # 扩展的实例化和初始化
    db.init_app(app)
    migrate.init_app(app, db)
    moment.init_app(app)
    ckeditor.init_app(app)
    mail.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
예제 #6
0
파일: __init__.py 프로젝트: xue000/Blog
def register_extensions(app):

    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    # mail.init_app(app)
    moment.init_app(app)
    # whooshee.init_app(app)
    csrf.init_app(app)
    migrate.init_app(app, db)
예제 #7
0
def register_extensions(app):
    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    dropzone.init_app(app)
    moment.init_app(app)
    whooshee.init_app(app)
    avatars.init_app(app)
    csrf.init_app(app)
    ckeditor.init_app(app)