Skip to content

fastapi_tools.params.load_env

Load environment variables from .env file.

Functions:

  • load_env

    Load environment variables from .env file.

load_env

load_env() -> None

Load environment variables from .env file.

Source code in src/fastapi_tools/params/load_env.py
def load_env() -> None:
    """Load environment variables from .env file."""
    # standard place to store credentials outside of version control and folder
    cred_path = Path.home() / "cred" / "fastapi-tools" / ".env"
    if cred_path.exists():
        load_dotenv(dotenv_path=cred_path)
        lg.debug(f"Loaded environment variables from {cred_path}")
    else:
        lg.debug(f".env file not found at {cred_path}")