-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.py
33 lines (25 loc) · 806 Bytes
/
server.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
from app import create_app
from app.models import db, User
import os, config , unittest
env_type = os.environ.get('FLASK_ENV', default='development')
app = create_app(env_type=env_type)
@app.cli.command()
def create_db():
try:
db.create_all(app=app)
except Exception as e:print(e)
@app.cli.command()
def test():
tests = unittest.TestLoader().discover('tests')
result = unittest.TextTestRunner(verbosity=2).run(tests)
@app.cli.command('seed-data')
def seed_data():
"""
creating user admin
"""
user = User(full_name='Gibran Abdillah', username='admin', email='[email protected]')
user.set_password('admin')
user.is_admin = True
user.save()
if __name__ == '__main__':
app.run(debug=True, port=os.environ.get('PORT','5000'), host='0.0.0.0')