Skip to content

Instantly share code, notes, and snippets.

@mitsuhiko
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitsuhiko/ce22eb7718d24aaed301 to your computer and use it in GitHub Desktop.
Save mitsuhiko/ce22eb7718d24aaed301 to your computer and use it in GitHub Desktop.
$ 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.
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