Docker flask application environment variables Docker flask application environment variables flask flask

Docker flask application environment variables


create file .env like this

model_path=./model/data_fs.csv

then install library .env by doing

pip3 install python-dotenv==0.17.1

add this to your code to load all your .env variable

from dotenv import load_dotenvload_dotenv()

so you can access it

if os.getenv("model_path", None) is not None:    return os.getenv("model_path", None)# otherwise raise an exceptionraise Exception("no .env file found")


you can try like this

import osos.environ["IP_AD"]