using the pycharm debugger with a flask application factory

Brian Leach picture Brian Leach · Apr 30, 2015 · Viewed 14.4k times · Source

I am typing more print statements than code. It's killing me.

If a flask development server is invoked via below, I can use PyCharm debugger

from ersapp import app

if __name__ == '__main__':
    app.run(debug=True)

I am following the example in Miguel Grinberg's book and an application manager (flask-script) is used. I invoke the server in my application directory like below

(env)$ python manage.py runserver

and in appdirectory/__init__.py

def create_app(config_name):
    webapp = Flask(__name__)
    ...
    return webapp

The debugger in Pycharm would make things easier since that's where I work.

Answer

Ráfagan picture Ráfagan · Sep 15, 2018

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

PyCharm configuration example