using the pycharm debugger with a flask application factory

Try configuring this python running configuration in "Edit Configurations". After that, run in debug mode.

PyCharm configuration example


If you are using the application factory pattern (i.e. using creat_app() WITHOUT a run.app() main) you can use your standard 'flask' run configuration template (community version may not have these, not sure). However, you'll notice that the debugger wont stop at breakpoints because the flask app in DEBUG runs the reloader which means it runs in different threads and Pycharm cant catch it. So to make it break not just at lunch but any API call you want to debug make sure you:

  • select DEBUG checkbox
  • add --no-reload as a flask argument
  • add --without-threads as a flask argument

This was the only way I could get full debug support:

Run Configuration