-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
51 lines (38 loc) · 1 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
49
50
51
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask.ext.script import Manager
from barrel import create_app
from barrel.extensions import db
from barrel.users.models import User
app = create_app()
manager = Manager(app)
@manager.command
def run():
"""Run in local machine."""
app.run()
@manager.command
def initdb():
"""Init/reset database."""
db.drop_all()
db.create_all()
#create admin
u = User(
username = 'admin',
email = '[email protected]',
first_name = 'admin',
last_name = 'admin',
avatar = '',
gender = 'm',
created = datetime.datetime.now(),
last_login = datetime.datetime.now(),
activated = True,
admin = True
)
u.set_password('admin')
u.save()
manager.add_option('-c', '--config',
dest="config",
required=False,
help="config file")
if __name__ == "__main__":
manager.run()