Run Flask with Debug in PyCharm

I have gotten to setting UP a Flask environment for a project recently. Was completely puzzled by how to run this. I have used to running Django project with python manage.py script. This means pointing out a PyCharm interpreter into a certain point of entry, that is also a .py file also.

In flask way of starting things there is another approach however. Here it is in Flask Docs.
It states to set a variable FLASK_APP and then run a flask run command. This will confuse running a python script way of a project being run. Thus to fix this one needs to set a path to flask binary file. It usually is within a virtual environment binary directory, place where your python interpreter resides.

So to set debugging one needs to set path to script binary one needs:
  • Script: /path/to/env/bin/flask
  • Script parameters: run 
  • Environment variable FLASK_APP=app.py
  • Environment variable FLASK_DEBUG=True
  • Set working directory back to your app path (It changes automatically according to script being set)
So my will look something like this:

Comments

Popular posts from this blog

Django: Resetting Passwords (with internal tools)

Time Capsule for $25

Vagrant error: * Unknown configuration section 'hostmanager'.