Run Flask CLI command with PyCharm debugger

邮差的信 提交于 2019-11-27 09:36:06

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. For example my_command --option A.
  • Edit the environment variables to include FLASK_APP=my_app and FLASK_ENV=development, the same way you'd use them from the terminal.
    • 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.

Running this configuration with the debugger will stop at breakpoints in your CLI command instead of running the server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!