1 Star 0 Fork 0

猫先森 / Infomation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
manage.py 944 Bytes
一键复制 编辑 原始数据 按行查看 历史
from flask import current_app
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from info import models
from info import create_app, db
# 创建app 并且传入配置模型 development/production
from info.models import User
app = create_app("development")
manager = Manager(app)
Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.option("-n", "-name", dest="name")
@manager.option("-p", "-password", dest="password")
def createsuperuser(name, password):
"""创建管理员"""
if not all([name, password]):
print("参数不足")
return
user = User()
user.nick_name = name
user.mobile = name
user.password = password
user.is_admin = True
try:
db.session.add(user)
db.session.commit()
except Exception as e:
db.session.callback()
current_app.logger.error(e)
if __name__ == '__main__':
manager.run()
Python
1
https://gitee.com/Mr__cat/Infomation_flask.git
git@gitee.com:Mr__cat/Infomation_flask.git
Mr__cat
Infomation_flask
Infomation
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891