예제 #1
0
def create_app():
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    static_dir = os.path.join(BASE_DIR, 'static')
    templates_dir = os.path.join(BASE_DIR, 'templates')

    app = Flask(__name__,
                static_folder=static_dir,
                template_folder=templates_dir)
    # 注册用户登录蓝图
    app.register_blueprint(blueprint=userlogin_bpt, url_prefix='/')

    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'mysql+mysqlconnector://root:[email protected]:3306/flaskdemo2'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # 设置session密钥
    app.config['SECRET_KEY'] = 'secret_key'

    db.init_app(app=app)

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

    return app
예제 #2
0
def createdb():
    db.create_all()
    return '创建成功'
예제 #3
0
def create_db():
    db.create_all()
    return '创建表成功'
예제 #4
0
파일: views.py 프로젝트: saozhuer/Falsk
def create_db():
    # 用于初次创建模型
    db.create_all()
    return '创建成功'
예제 #5
0
def create_db():
    db.create_all()
    return '数据库创建成功'
예제 #6
0
def create_db():
    # 用于初次创建models中所有的表
    db.create_all()
    return '创建成功'