Skip to content

Instantly share code, notes, and snippets.

@tonyseek
Last active December 29, 2015 06:09
Show Gist options
  • Save tonyseek/7627052 to your computer and use it in GitHub Desktop.
Save tonyseek/7627052 to your computer and use it in GitHub Desktop.
Flask App Management Script
#!/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