Cli Documentation of the Flask app

Flask Cli

Cli entry point for autodoc tooling.

flask [OPTIONS] COMMAND [ARGS]...

Options

-e, --env-file <env_file>

Load environment variables from this file. python-dotenv must be installed.

-A, --app <IMPORT>

The Flask application or factory function to load, in the form ‘module:name’. Module can be a dotted import or file path. Name is not required if it is ‘app’, ‘application’, ‘create_app’, or ‘make_app’, and can be ‘name(args)’ to pass arguments.

--debug, --no-debug

Set debug mode.

--version

Show the Flask version.

routes

Show all registered routes with endpoints and methods.

flask routes [OPTIONS]

Options

-s, --sort <sort>

Method to sort routes by. ‘match’ is the order that Flask will match routes when dispatching a request.

Options:

endpoint | methods | domain | rule | match

--all-methods

Show HEAD and OPTIONS methods.

run

Run a local development server.

This server is for development purposes only. It does not provide the stability, security, or performance of production WSGI servers.

The reloader and debugger are enabled by default with the ‘–debug’ option.

flask run [OPTIONS]

Options

--debug, --no-debug

Set debug mode.

-h, --host <host>

The interface to bind to.

-p, --port <port>

The port to bind to.

--cert <cert>

Specify a certificate file to use HTTPS.

--key <key>

The key file to use when specifying a certificate.

--reload, --no-reload

Enable or disable the reloader. By default the reloader is active if debug is enabled.

--debugger, --no-debugger

Enable or disable the debugger. By default the debugger is active if debug is enabled.

--with-threads, --without-threads

Enable or disable multithreading.

--extra-files <extra_files>

Extra files that trigger a reload on change. Multiple paths are separated by ‘:’.

--exclude-patterns <exclude_patterns>

Files matching these fnmatch patterns will not trigger a reload on change. Multiple patterns are separated by ‘:’.

shell

Run an interactive Python shell in the context of a given Flask application. The application will populate the default namespace of this shell according to its configuration.

This is useful for executing small snippets of management code without having to manually configure the application.

flask shell [OPTIONS]

DB Cli for Development

flask [OPTIONS] COMMAND [ARGS]...

create-and-load-db

Create all db tables and load testdata.

flask create-and-load-db [OPTIONS]

drop-db

Drop all db tables.

flask drop-db [OPTIONS]

load-providers

Load provider data into the database.

flask load-providers [OPTIONS]

load-test-data

Load database test data

flask load-test-data [OPTIONS]

recreate-and-load-db

(Re-)create all db tables.

flask recreate-and-load-db [OPTIONS]

DB Cli for Migrations

Perform database migrations.

flask db [OPTIONS] COMMAND [ARGS]...

Options

-x, --x-arg <x_arg>

Additional arguments consumed by custom env.py scripts

branches

Show current branch points

flask db branches [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-v, --verbose

Use more verbose output

check

Check if there are any new operations to migrate

flask db check [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

current

Display the current revision for each database.

flask db current [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-v, --verbose

Use more verbose output

downgrade

Revert to a previous version

flask db downgrade [OPTIONS] [REVISION]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

--sql

Don’t emit SQL to database - dump to standard output instead

--tag <tag>

Arbitrary “tag” name - can be used by custom env.py scripts

-x, --x-arg <x_arg>

Additional arguments consumed by custom env.py scripts

Arguments

REVISION

Optional argument

edit

Edit a revision file

flask db edit [OPTIONS] [REVISION]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

Arguments

REVISION

Optional argument

heads

Show current available heads in the script directory

flask db heads [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-v, --verbose

Use more verbose output

--resolve-dependencies

Treat dependency versions as down revisions

history

List changeset scripts in chronological order.

flask db history [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-r, --rev-range <rev_range>

Specify a revision range; format is [start]:[end]

-v, --verbose

Use more verbose output

-i, --indicate-current

Indicate current version (Alembic 0.9.9 or greater is required)

init

Creates a new migration repository.

flask db init [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

--multidb

Support multiple databases

-t, --template <template>

Repository template to use (default is “flask”)

--package

Write empty __init__.py files to the environment and version locations

list-templates

List available templates.

flask db list-templates [OPTIONS]

merge

Merge two revisions together, creating a new revision file

flask db merge [OPTIONS] [REVISIONS]...

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-m, --message <message>

Merge revision message

--branch-label <branch_label>

Specify a branch label to apply to the new revision

--rev-id <rev_id>

Specify a hardcoded revision id instead of generating one

Arguments

REVISIONS

Optional argument(s)

migrate

Autogenerate a new revision file (Alias for ‘revision –autogenerate’)

flask db migrate [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-m, --message <message>

Revision message

--sql

Don’t emit SQL to database - dump to standard output instead

--head <head>

Specify head revision or <branchname>@head to base new revision on

--splice

Allow a non-head revision as the “head” to splice onto

--branch-label <branch_label>

Specify a branch label to apply to the new revision

--version-path <version_path>

Specify specific path from config for version file

--rev-id <rev_id>

Specify a hardcoded revision id instead of generating one

-x, --x-arg <x_arg>

Additional arguments consumed by custom env.py scripts

revision

Create a new revision file.

flask db revision [OPTIONS]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

-m, --message <message>

Revision message

--autogenerate

Populate revision script with candidate migration operations, based on comparison of database to model

--sql

Don’t emit SQL to database - dump to standard output instead

--head <head>

Specify head revision or <branchname>@head to base new revision on

--splice

Allow a non-head revision as the “head” to splice onto

--branch-label <branch_label>

Specify a branch label to apply to the new revision

--version-path <version_path>

Specify specific path from config for version file

--rev-id <rev_id>

Specify a hardcoded revision id instead of generating one

show

Show the revision denoted by the given symbol.

flask db show [OPTIONS] [REVISION]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

Arguments

REVISION

Optional argument

stamp

‘stamp’ the revision table with the given revision; don’t run any migrations

flask db stamp [OPTIONS] [REVISION]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

--sql

Don’t emit SQL to database - dump to standard output instead

--tag <tag>

Arbitrary “tag” name - can be used by custom env.py scripts

--purge

Delete the version in the alembic_version table before stamping

Arguments

REVISION

Optional argument

upgrade

Upgrade to a later version

flask db upgrade [OPTIONS] [REVISION]

Options

-d, --directory <directory>

Migration script directory (default is “migrations”)

--sql

Don’t emit SQL to database - dump to standard output instead

--tag <tag>

Arbitrary “tag” name - can be used by custom env.py scripts

-x, --x-arg <x_arg>

Additional arguments consumed by custom env.py scripts

Arguments

REVISION

Optional argument

Flask-Smorest Cli for OpenAPI Spec

OpenAPI commands.

flask openapi [OPTIONS] COMMAND [ARGS]...

list-config-prefixes

List available API config prefixes.

flask openapi list-config-prefixes [OPTIONS]

print

Print OpenAPI JSON document.

flask openapi print [OPTIONS]

Options

-f, --format <format>
Options:

json | yaml

--config-prefix <config_prefix>

write

Write OpenAPI JSON document to a file.

flask openapi write [OPTIONS] OUTPUT_FILE

Options

-f, --format <format>
Options:

json | yaml

--config-prefix <config_prefix>

Arguments

OUTPUT_FILE

Required argument