PyCharm’s “Flask server” configuration only calls the flask run
command, it doesn’t provide a way to call other commands. To do that, create a regular “Python” configuration that runs the flask
command with the arguments you want.
- Create a “Python” configuration and give it a name.
- Select “Module name” instead of “Script path” and type
flask
. - Fill out “Parameters” with the arguments to pass. As of Flask 2.2, you can use the
--app
and--debug
options. For example--app my_app my_command --option A
.- Prior to Flask 2.2, edit the environment variables to include
FLASK_APP=my_app
andFLASK_ENV=development
. - You may also need to configure “Working directory” to point at your project directory, if your command depends on where it’s being run from.
- Prior to Flask 2.2, edit the environment variables to include
Running this configuration with the debugger will stop at breakpoints in your CLI command instead of running the server.