Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using the pycharm debugger with a flask application factory

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.

like image 440
Brian Leach Avatar asked Apr 30 '15 06:04

Brian Leach


People also ask

How do I debug a Flask app in PyCharm?

The default value is 'development'. Select this checkbox to enable the built-in Flask debug mode. With this mode, the development server will be automatically reloaded on any code change enabling continuous debugging.

Does PyCharm work with Flask?

PyCharm supports Flask development including: Dedicated project type. Support for the built-in Flask debugger. Flask command-line interface (CLI).


1 Answers

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

PyCharm configuration example

like image 66
Ráfagan Avatar answered Oct 02 '22 13:10

Ráfagan