diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..bfca245 --- /dev/null +++ b/.env.prod @@ -0,0 +1 @@ +OPENAPI_URL="" diff --git a/.gitignore b/.gitignore index 35f0eb3..d1459a0 100644 --- a/.gitignore +++ b/.gitignore @@ -197,3 +197,4 @@ cython_debug/ poetry.lock datings.db +.env.local diff --git a/LeraFoxQueen/main.py b/LeraFoxQueen/main.py index f1a8120..67dd4c6 100644 --- a/LeraFoxQueen/main.py +++ b/LeraFoxQueen/main.py @@ -13,6 +13,22 @@ from .router import router as datings_router from .validity import is_valid_uuid +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class Settings(BaseSettings): + OPENAPI_URL: str = "/openapi.json" + + model_config = SettingsConfigDict( + env_file=(".env", ".env.local", ".env.prod"), + env_file_encoding="utf-8", + case_sensitive=True + ) + + +settings = Settings() + + @asynccontextmanager async def lifespan(app: FastAPI): await create_tables() @@ -23,8 +39,9 @@ async def lifespan(app: FastAPI): pass -# app = FastAPI(lifespan=lifespan) -app = FastAPI(lifespan=lifespan, docs_url=None, redoc_url=None, openapi_url=None) +app = FastAPI( + lifespan=lifespan, docs_url=None, redoc_url=None, openapi_url=settings.OPENAPI_URL +) templates = Jinja2Templates(directory="templates") diff --git a/pyproject.toml b/pyproject.toml index 4ec5650..5e7a2d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ dependencies = [ "idna (>=3.10,<4.0)", "sniffio (>=1.3.1,<2.0.0)", "jinja2 (>=3.1.6,<4.0.0)", + "pydantic-settings (>=2.9.1,<3.0.0)", ] package-mode = false