Beispiel #1
0
def register_plugin(app):
    from app.model.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()

    print('register_plugin')
Beispiel #2
0
def create_app():
    from app.web.util.util import refresh_control_info

    app = Flask(__name__)
    app.config.from_pyfile('secure.py')
    app.config.from_pyfile('settings.py')
    # 注册SQLAlchemy
    db.init_app(app)

    # 注册login模块
    login_manager.init_app(app)
    login_manager.login_view = 'web.login'
    login_manager.login_message = '请先登录或注册'

    # 注册admin模块
    from app.model.user import User
    from app.model.vote import VoteEvent
    admin = Admin(app=app, name='后台管理系统', template_mode='bootstrap3')
    admin.add_view(UserModelView(User, db.session, name='用户管理'))
    admin.add_view(VoteEventModelView(VoteEvent, db.session, name='投票管理'))

    # 国际化
    babel = Babel()
    babel.init_app(app)

    # 刷新投票控制信息
    with app.app_context():
        refresh_control_info()

    return app
Beispiel #3
0
def create_app(env):
    app = Flask(__name__)
    CORS(app, supports_credentials=True)
    app.config.from_object("app.config.%s.secure" % env)
    app.config.from_object("app.config.%s.setting" % env)
    register_blueprint(app)
    db.init_app(app)
    return app
Beispiel #4
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    bootstrap.init_app(app)
    db.init_app(app)
    auth.loginManager.init_app(app)
    moment.init_app(app)
    register_app(app)
    return app
Beispiel #5
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name]())
    if config_name != 'production':
        CORS(app)
    register_blueprint(app)
    db.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)
    return app
Beispiel #6
0
def create_app():
    app = Flask(__name__)
    CORS(app)
    app.config.from_object("app.secure")
    app.config.from_object("app.setting")
    register_blueprint(app)

    db.init_app(app)
    with app.app_context():
        db.create_all()
    return app
Beispiel #7
0
def current_app():
    app = Flask(__name__)
    app.config.from_object('app.config')
    app.config.from_object('app.secure')
    register_blueprint(app)
    db.init_app(app)
    db.create_all(app=app)
    login_manager.init_app(app=app)
    login_manager.login_view = 'web.login'
    login_manager.login_message = '请先登录或注册'
    mail.init_app(app)
    return app
Beispiel #8
0
def create_app():
    #实例化核心对象
    app = Flask(__name__)
    register_blueprint(app)
    app.config.from_object('app.secure')
    app.config.from_object('app.setting')
    db.init_app(app)

    with app.app_context():
        db.create_all()

    return app
Beispiel #9
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('config.app')
    app.config.from_object('config.database')
    register_buleprint(app)

    db.init_app(app)
    login_manager.init_app(app)
    login_manager.login_view = 'web.login'
    login_manager.login_message = '请先登陆或注册'
    with app.app_context():
        db.create_all()

    return app
Beispiel #10
0
def create_app():
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object('app.setting')
    app.config.from_pyfile(
        'secure.py'
    )  #用Flask()创建应用时设置了instance_relative_config=True,app.config.from_pyfile()将查看在instance文件夹的特殊文件。
    # app.register_blueprint(web)
    db.init_app(app)
    login_manager.init_app(app)
    login_manager.login_view = 'web.login'
    login_manager.login_message = '请先登录或者注册'
    register_blueprint(app)
    mail.init_app(app)
    with app.app_context():
        db.create_all()

    return app
Beispiel #11
0
def register_plugin(app):
    """注册插件"""
    from app.model.base import db
    db.init_app(app)
    with app.app_context():
        db.create_all()
Beispiel #12
0
from flask import Flask as Flask, request, make_response, jsonify, g
from sqlalchemy import text

from app.model.base import db, Token

app = Flask(__name__)

# 加载配置文件
app.config.from_object('app.config')

# 注册蓝图
from app.api import api

app.register_blueprint(api)

db.init_app(app)


@app.before_request
def before_filter():
    # r = request
    # ip = request.remote_addr
    # url = request.url

    endpoint = request.endpoint
    print(endpoint)

    # auth_开头的接口不做验证
    if (endpoint is None or endpoint.startswith('api.auth_')) or endpoint in [
            'api.monitor_collect'
    ]: