-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·44 lines (33 loc) · 1.08 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
#!/usr/bin/env python
import os
from flask.ext.script import Manager, Server
from flask.ext.script.commands import ShowUrls, Clean
from flask.ext.migrate import Migrate, MigrateCommand
from ticketplace import create_app
from ticketplace.models import db
# default to dev config because no one should use this in
# production anyway
config_name = os.environ.get('CONFIG', 'ticketplace.settings.DevelopmentConfig')
app = create_app(config_name)
migrate = Migrate(app=app,
db=db,
compare_type=True)
manager = Manager(app)
manager.add_command("server", Server())
manager.add_command("show-urls", ShowUrls())
manager.add_command("clean", Clean())
manager.add_command('db', MigrateCommand)
@manager.shell
def make_shell_context():
""" Creates a python REPL with several default imports
in the context of the app
"""
return dict(app=app, db=db)
@manager.command
def createdb():
""" Creates a database with all of the tables defined in
your SQLAlchemy models
"""
db.create_all()
if __name__ == "__main__":
manager.run()