Home > database >  Simplest way to load .env file with `flask run` cli command?
Simplest way to load .env file with `flask run` cli command?

Time:05-02

There must be a simple way to load a .env environment file when launching a Flask app with the cli command flask run. I cant find an answer anywhere they all suggest loading the variables with python which I don't want to do. I am trying to run this on a Linux machine.

CodePudding user response:

pip install python-dotenv

Then place this in the app.py file

from dotenv import load_dotenv

load_dotenv()

  • Related