Exemplo n.º 1
0
def create_app(fs: str = 'settings.py'):
    app = Flask(__name__)
    cnf = os.getenv('FLASK_ENV')
    if cnf.lower().startswith('dev'):
        app.config.from_object(DevConfig)
    else:
        app.config.from_object(DevConfig)

    crsf.init_app(app)

    # Server-side session config
    app.config["SESSION_TYPE"] = 'sqlalchemy'
    app.config["SESSION_PERMANENT"] = True
    app.config['PERMANENT_SESSION_LIFETIME'] = 6000
    app.config["SESSION_USE_SIGNER"] = True
    app.config["SESSION_SQLALCHEMY"] = db
    app.config["SESSION_SQLALCHEMY_TABLE"] = "sessions"
    sess = Session()
    sess.init_app(app)

    ckeditor.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)

    app.register_blueprint(main)

    # Acquisizione della configurazione per il generatore e altri dati
    # di configurazione
    with app.app_context():
        _, objlist = GeneratorConfig.parse_config()
        diz = dict()
        for obj in objlist:
            diz[obj.conf_key] = obj.conf_value
        set_builder_conf(diz)
    return app
Exemplo n.º 2
0
def register_extensions(app):

    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
    ckeditor.init_app(app)
Exemplo n.º 3
0
def register_plugin(app):
    db.init_app(app)
    bootstrap.init_app(app)
    moment.init_app(app)
    mail.init_app(app)
    ckeditor.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
Exemplo n.º 4
0
def register_extensions(app):
    bootstrap.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    mail.init_app(app)
    login_manager.init_app(app)
    toolbar.init_app(app)
    cache.init_app(app)
    ckeditor.init_app(app)
Exemplo n.º 5
0
def register_extensions(app):
    bootstrap.init_app(app)
    db.init_app(app)
    login.init_app(app)
    csrf.init_app(app)
    ckeditor.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    toolbar.init_app(app)
    migrate.init_app(app, db)
Exemplo n.º 6
0
def register_extensions(app):
    """初始化拓展"""
    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
    ckeditor.init_app(app)
    moment.init_app(app)
    avatars.init_app(app)
    whooshee.init_app(app)
Exemplo n.º 7
0
def register_extensions(app):
    
    db.init_app(app)
    bootstrap.init_app(app)
    ckeditor.init_app(app)
    login_manager.init_app(app)
    csrf.init_app(app)
    pagedown.init_app(app)
    moment.init_app(app)
    migrate.init_app(app, db)
    sitemap.init_app(app)
    search.init_app(app)
Exemplo n.º 8
0
def register_extensions(app):
    # 添加数据库
    db.init_app(app)
    # 迁移数据库
    migrate.init_app(app, db)

    # 加载插件
    login_manager.init_app(app)
    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    babel.init_app(app)
    # 富文本插件
    ckeditor.init_app(app)
    csrf.init_app(app)
Exemplo n.º 9
0
def register_extensions(app):
    db.init_app(app)
    migrate.init_app(app, db)
    login.init_app(app)
    mail.init_app(app)
    bootstrap.init_app(app)
    moment.init_app(app)
    babel.init_app(app)
    ckeditor.init_app(app)
    csrf.init_app(app)
    avatars.init_app(app)

    from app.api import bp as api_bp
    csrf.exempt(api_bp)

    app.elasticsearch = Elasticsearch([
        app.config['ELASTICSEARCH_URL']
    ]) if app.config['ELASTICSEARCH_URL'] else None
    app.redis = Redis.from_url(app.config['REDIS_URL'])
    app.task_queue = rq.Queue('microblog-tasks', connection=app.redis)
Exemplo n.º 10
0
def create_app(config_name=None):
    if config_name is None:
        config_name = os.getenv('FLASK_CONFIG', 'production')

    app = Flask('app')
    app.app_context().push()
    app.config.from_object(config[config_name])
    ckeditor.init_app(app)
    csrf.init_app(app)
    qrcode.init_app(app)
    register_errors(app)
    register_logging(app)
    register_blueprints(app)
    register_extensions(app)
    register_shell_context(app)
    register_commands(app)
    register_template_context(app)
    migrate.init_app(app, db)
    assets.init_app(app)
    cache.init_app(app)
    debug.init_app(app)
    return app
Exemplo n.º 11
0
def register_extensions(app):
    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    ckeditor.init_app(app)
Exemplo n.º 12
0
def register_extensions(app):
    db.init_app(app)
    login_manager.init_app(app)
    migrate.init_app(app, db)
    ckeditor.init_app(app)
    get_file_init(app)