Search code examples
pythonfabric

python fabric: set environment variable


I have a question that is somehow covered by documentation but I simply do not understand it.

I want to start a flask app and set two shell environment variables first:

export FLASK_APP=startup.py
export DEBUG=1
pipenv run flask db upgrade

In fabric I run the second command:

run("pipenv run flask db upgrade")

But It eludes me on how to set the environment variables. I read all the examples but I dont understand them.


Solution

  • You could make use of what is talked about in this answer or this one

    Thus:

    run("env FLASK_APP=startup.py DEBUG=1 pipenv run flask db upgrade")