Config.py < 100% RECOMMENDED >

from pydantic_settings import BaseSettings class Settings(BaseSettings): database_url: str port: int = 8080 settings = Settings() Use code with caution. Copied to clipboard

The most straightforward approach is defining variables directly in a .py file and importing them. config.py

: Your logic doesn't need to know where a database is; it just needs the connection string provided by the config. config.py

class Config: SECRET_KEY = "base-key" class ProductionConfig(Config): DEBUG = False Use code with caution. Copied to clipboard Best Practices for Your Config Working with Credentials and Configurations in Python config.py

Loading...