-
Notifications
You must be signed in to change notification settings - Fork 36
/
manage.py
48 lines (39 loc) · 1.15 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
45
46
47
48
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File : manage.py
# Author: jixin
# Date : 18-10-17
import os
from app import app
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import db
from app.auth.models import User
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
@manager.command
def test():
from subprocess import call
call(['nosetests', '-v',
'--with-coverage', '--cover-package=app', '--cover-branches',
'--cover-erase', '--cover-html', '--cover-html-dir=cover'])
@manager.command
def adduser(email, username, admin=False):
"""Register a new user."""
from getpass import getpass
password = getpass()
password2 = getpass(prompt='Confirm: ')
if password != password2:
import sys
sys.exit('Error: passwords do not match.')
db.create_all()
user = User(username=username, password=password)
db.session.add(user)
db.session.commit()
print('User {0} was registered successfully.'.format(username))
@manager.command
def runserver():
app.run()
if __name__ == '__main__':
manager.run()