Last active
December 29, 2015 06:09
-
-
Save tonyseek/7627052 to your computer and use it in GitHub Desktop.
Flask App Management Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from flask_script import Manager | |
from myapp.app import create_app | |
from myapp.ext import db, oauth | |
app = create_app() | |
manager = Manager(app) | |
@manager.shell | |
def shell_context(): | |
return dict(app=app, db=db, oauth=oauth) | |
@manager.command | |
def syncdb(destory=False, verbose=False): | |
"""Creates or destroys the database.""" | |
db.engine.echo = bool(verbose) | |
if destory: | |
db.drop_all() | |
db.create_all() | |
if __name__ == "__main__": | |
manager.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment