Last active
August 29, 2015 14:01
-
-
Save mitsuhiko/ce22eb7718d24aaed301 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$ flask -a myapp | |
Usage: flask [OPTIONS] COMMAND [ARGS]... | |
This shell command acts as general utility script for Flask applications. | |
It loads the application configured (either through the FLASK_APP | |
environment variable or the --app parameter) and then provides commands | |
either provided by the application or Flask itself. | |
The most useful commands are the "run" and "shell" command. | |
Example usage: | |
flask --app=hello --debug run | |
Options: | |
-a, --app TEXT The application to run | |
--debug / --no-debug Enable or disable debug mode. | |
--help Show this message and exit. | |
Commands: | |
initdb Initializes the database. | |
run Runs a development server. | |
shell Runs a shell in the app context. |
This file contains hidden or 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
import click | |
from flask import Flask | |
app = Flask(__name__) | |
@app.cli.command() | |
@click.option('--dry-run', is_flag=True) | |
def initdb(dry_run): | |
"""Initializes the database.""" | |
print('Initialized the database') | |
if dry_run: | |
print('Did not actually do anything') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment