Commit 665c1e4372e93a8498e45cbe40b793309bf70662
1 parent
a9d173ce
Exists in
master
Add the good ole `manage.py`.
… Sigh.
Showing
1 changed file
with
42 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +#!/usr/bin/env python | ||
2 | + | ||
3 | +import os | ||
4 | + | ||
5 | +from flask_script import Manager, Server | ||
6 | +from flask_script.commands import ShowUrls, Clean | ||
7 | +from flaskr import create_app | ||
8 | +from flaskr.models import db, User | ||
9 | + | ||
10 | +# default to dev config because no one should use this in | ||
11 | +# production anyway | ||
12 | +env = os.environ.get('APPNAME_ENV', 'dev') | ||
13 | +app = create_app('flaskr.settings.%sConfig' % env.capitalize()) | ||
14 | + | ||
15 | +manager = Manager(app) | ||
16 | +manager.add_command("server", Server()) | ||
17 | +manager.add_command("show-urls", ShowUrls()) | ||
18 | +manager.add_command("clean", Clean()) | ||
19 | + | ||
20 | + | ||
21 | +@manager.shell | ||
22 | +def make_shell_context(): | ||
23 | + """ | ||
24 | + Creates a python REPL with several default imports | ||
25 | + in the context of the app | ||
26 | + """ | ||
27 | + | ||
28 | + return dict(app=app, db=db, User=User) | ||
29 | + | ||
30 | + | ||
31 | +@manager.command | ||
32 | +def createdb(): | ||
33 | + """ | ||
34 | + Creates a database with all of the tables defined in | ||
35 | + your SQLAlchemy models | ||
36 | + """ | ||
37 | + | ||
38 | + db.create_all() | ||
39 | + | ||
40 | + | ||
41 | +if __name__ == "__main__": | ||
42 | + manager.run() |