Skip to main content

load_dotenv

Load "dotenv" files to set environment variables. A given path takes precedence over .env, which takes precedence over .flaskenv. After loading and combining these files, values are only set if the key is not already set in os.environ.

def load_dotenv(
path: str | os.PathLike[str] | None = None,
load_defaults: bool = True
) - > bool

Load "dotenv" files to set environment variables. A given path takes precedence over .env, which takes precedence over .flaskenv. After loading and combining these files, values are only set if the key is not already set in os.environ.

Parameters

NameTypeDescription
path`stros.PathLike[str]
load_defaultsbool = TrueWhether to search for and load the default .flaskenv and .env files in the current directory.

Returns

TypeDescription
boolTrue if at least one env var was loaded.