Skip to content

config

Environment Variables

  • .env
    • Use this file when you want to set environment variables for the project.
  • .env.local
    • Use this file when you want to set environment variables for the local environment.

Addendum environment variables to tools/config/settings.py:

tools/config/settings.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Settings(BaseSettings):
    """Environment variables settings."""

    model_config = SettingsConfigDict(
        env_file=(".env", ".env.local"),
        env_file_encoding="utf-8",
    )

    DEBUG: bool = False
    IS_LOCAL: bool = False

FastAPI

1
2
3
4
5
6
7
from fastapi import FastAPI

from tools import Settings


settings = Settings()
app = FastAPI(**settings.fastapi_kwargs)