flask
Python web microframework CLI
TLDR
Run the development server
SYNOPSIS
flask [--app module] [--debug] command [options]
DESCRIPTION
flask is the command-line interface for Flask, a popular Python web microframework. It provides commands for running development servers, opening application shells, and executing custom commands defined by Flask extensions or the application.
The CLI discovers the Flask application through the FLASK_APP environment variable or --app option. It supports loading from modules (app), module:app patterns (myapp:create_app()), or factory functions.
The development server (flask run) includes an auto-reloader that restarts when code changes and an interactive debugger that appears in the browser on errors. These features should only be used in development, never in production.
Flask extensions often add their own CLI commands. Flask-Migrate adds flask db commands for database migrations, Flask-Admin might add admin commands, etc. Applications can define custom commands using the @app.cli.command() decorator.
The shell command provides an interactive Python session with the application and its context pre-loaded, useful for testing and debugging.
PARAMETERS
--app module
Specify the Flask application module (or set FLASK_APP environment variable).--debug / --no-debug
Enable/disable debug mode with auto-reloader and debugger.run [--host host] [--port port]
Run the development server.shell
Open an interactive Python shell with application context.routes [--sort endpoint|methods|rule]
Show all registered URL rules.--version
Show Flask version.--help
Show help for a command.
RUN OPTIONS
--host address
Network interface to bind to (default: 127.0.0.1).--port port
Port to listen on (default: 5000).--reload / --no-reload
Enable/disable auto-reload on code changes.--debugger / --no-debugger
Enable/disable the interactive debugger.--cert path
SSL certificate file for HTTPS.--key path
SSL key file for HTTPS.
CAVEATS
The development server is not suitable for production use. Debug mode exposes sensitive information and should never be enabled in production. The server is single-threaded by default. Use a production WSGI server like Gunicorn or uWSGI for deployment.
HISTORY
Flask was created by Armin Ronacher in 2010 as part of an April Fools' joke that became popular. The CLI was added in Flask 0.11 (2016), replacing the older flask-script extension and server startup method. Flask has become one of the most widely used Python web frameworks.
SEE ALSO
gunicorn(1), uvicorn(1), python(1), pip(1), django-admin(1)
