forked from laoqiu/sinaapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
31 lines (22 loc) · 704 Bytes
/
manage.py
File metadata and controls
31 lines (22 loc) · 704 Bytes
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
#!/usr/bin/env python
#coding=utf-8
from flask import Flask, current_app
from flaskext.script import Server, Shell, Manager, Command
from webapp import create_app
from webapp.extensions import db
manager = Manager(create_app('config.cfg'))
manager.add_command("runserver", Server('0.0.0.0',port=80))
def _make_context():
return dict(db=db)
manager.add_command("shell", Shell(make_context=_make_context))
@manager.command
def createall():
"Creates database tables"
db.create_all()
@manager.command
def dropall():
"Drops all database tables"
if prompt_bool("Are you sure ? You will lose all your data !"):
db.drop_all()
if __name__ == "__main__":
manager.run()