-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·44 lines (33 loc) · 1.33 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""This file sets up a command line manager.
Use "python manage.py" for a list of available commands.
Use "python manage.py runserver" to start the development web server on localhost:5000.
Use "python manage.py runserver --help" for additional runserver options.
"""
import unittest
try:
from colour_runner.runner import ColourTextTestRunner as TextTestRunner
except ImportError:
from unittest.runner import TextTestRunner
from flask_migrate import MigrateCommand, Migrate
from flask_script import Manager, Shell, Server
from app import create_app, db
# Setup Flask-Script with command line commands
app, socketio = create_app()
manager = Manager(app)
migrate = Migrate(app, db)
@manager.command
def test():
"""Runs the unit tests without test coverage."""
tests = unittest.TestLoader().discover('tests', pattern='test*.py')
result = TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
manager.add_command('db', MigrateCommand)
manager.add_command("shell", Shell(make_context=lambda: dict(app=app, db=db)))
manager.add_command('runserver', Server(threaded=True))
if __name__ == "__main__":
# python manage.py # shows available commands
# python manage.py runserver --help # shows available runserver options
manager.run()