Flask Blueprint CLI commands

Flask Tip - Custom CLI Commands

Custom CLI commands in Flask can be added to specific blueprints, not just to the Flask application.


import click
from flask import Blueprint

users_blueprint = Blueprint('users', __name__)

def create(email):
    """Create a new user."""
    click.echo(f'Added new user (email: {email}!')

# in terminal
$ flask users --help

  create  Create a new user.