Exemple #1
0
#!/usr/bin/env python
import os
from app import creat_app, db
from app.models import User
from flask_script import Manager, Shell

app = creat_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, User=User)


manager.add_command("shell", Shell(make_shell_context))

if __name__ == '__main__':
    manager.run()
Exemple #2
0
 def setUp(self):
     self.app = creat_app('testing')
     self.app_context = self.app.app_context()
     self.create_all()
Exemple #3
0
from app import creat_app, db
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from app.models import User, Role, Post, Category, Comment, Follow, ApplyForBestPost
import os

if os.path.exists('.env'):
    print("Importing environment from .env")
    for line in open('.env'):
        var = line.strip().split('=')
        if len(var) == 2:
            os.environ[var[0]] = var[1]

app = creat_app(os.getenv('TJ_CONFIG') or 'default')
migrate = Migrate(app, db)
manager = Manager(app)


def make_shell_context():
    return dict(app=app,
                db=db,
                User=User,
                Role=Role,
                Category=Category,
                Post=Post,
                Comment=Comment,
                Follow=Follow,
                ApplyForBestPost=ApplyForBestPost)


manager.add_command('shell', Shell(make_context=make_shell_context))
# -*- coding: utf-8 -*-
# @Time    : 2020/2/29 下午5:44
# @Author  : Thanlon
# @Wechat:18512152005
# @Email   : [email protected]
# @File    : manage.py
# @Software: PyCharm
from app import creat_app

app = creat_app()
if __name__ == '__main__':
    app.run()
Exemple #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from app import creat_app, db
from app.models import Role, User
from flask_script import Manager, Shell
from gevent import monkey

monkey.patch_all()

app = creat_app('default')
manager = Manager(app)


def make_shell_context():
    return dict(app=app, db=db, Role=Role, User=User)


manager.add_command("shell", Shell(make_context=make_shell_context))


@manager.command
def test():
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)


if __name__ == '__main__':
    manager.run()
Exemple #6
0
from app import creat_app

application = creat_app('production')

if __name__ == '__main__':
    application.run(port='9999')