-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
44 lines (32 loc) · 973 Bytes
/
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
import os
import unittest
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask import current_app
from werkzeug.local import LocalProxy
from dotenv import load_dotenv
from app import create_app, db
from app.api import api
from infrastructor.exceptions import errors
logger = LocalProxy(lambda: current_app.logger)
load_dotenv()
app = create_app(os.getenv('APP_ENV'))
app.register_blueprint(api)
app.register_blueprint(errors)
app.app_context().push()
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.command
def run():
app.run(debug=True, host="0.0.0.0", port=5000)
@manager.command
def test():
"""Runs the unit tests."""
tests = unittest.TestLoader().discover('test', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
if __name__ == '__main__':
manager.run()