1 Star 0 Fork 2

石头 / flask-upms

forked from quanyongan / flask-upms 
Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
manage.py 1.04 KB
Copy Edit Web IDE Raw Blame History
quanyongan authored 2018-03-20 08:38 . 首次提交版本
# -*- coding: utf-8 -*-
"""
Created by Quant on 2018-03-07
"""
__author__ = 'Quant'
import os
from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from app import create_app
from app import models
# 获取环境变量中配置的CLOUD_ENV,不设置(Prod、Test、Dev),默认就是dev
env = os.environ.get('CLOUD_ENV', 'dev')
# 工厂方法创建app
app = create_app('app.config.{}Config'.format(env.capitalize()))
# 创建命令行解释器
manager = Manager(app)
# 初始化migrate
migrate = Migrate(app, models.db)
# 创建命令行可执行的命令
manager.add_command("server", Server(host=app.config['HOST'],
port=app.config['PORT'],
use_debugger=app.config['DEBUG']))
manager.add_command("db", MigrateCommand)
@manager.shell
def make_shell_context():
return dict(app=app,
db=models.db,
User=models.User
)
if __name__ == '__main__':
manager.run(default_command="server")

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/lantian316/flask-upms.git
git@gitee.com:lantian316/flask-upms.git
lantian316
flask-upms
flask-upms
master

Search