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
def createdb(): db.create_all() return '创建成功'
def create_db(): db.create_all() return '创建表成功'
def create_db(): # 用于初次创建模型 db.create_all() return '创建成功'
def create_db(): db.create_all() return '数据库创建成功'
def create_db(): # 用于初次创建models中所有的表 db.create_all() return '创建成功'