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 automatically search for and load the standard .flaskenv and .env files from the current directory.

Returns

TypeDescription
boolTrue if at least one environment variable was successfully loaded into the process environment.