From b541fdf57a457f277a744af4bb35f4c5b01cf95b Mon Sep 17 00:00:00 2001 From: proDream Date: Fri, 10 Jan 2025 05:07:38 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=20FastAPI?= =?UTF-8?q?=20=D1=81=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=D0=BC=20uvicorn=20=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B0=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Добавлена поддержка утилиты uvicorn для запуска приложения FastAPI. - Создан новый модуль `settings.py` в пакете `core`, содержащий настройки базы данных. --- lkeep/core/__init__.py | 0 lkeep/core/settings.py | 24 ++++++++++++++++++++++++ lkeep/main.py | 6 +++--- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 lkeep/core/__init__.py create mode 100644 lkeep/core/settings.py diff --git a/lkeep/core/__init__.py b/lkeep/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lkeep/core/settings.py b/lkeep/core/settings.py new file mode 100644 index 0000000..6124d1f --- /dev/null +++ b/lkeep/core/settings.py @@ -0,0 +1,24 @@ +from pydantic import SecretStr +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class DBSettings(BaseSettings): + db_name: str + db_user: str + db_password: SecretStr + db_host: str + db_port: int + db_echo: bool + + model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf8", extra="ignore") + + @property + def db_url(self): + return f"postgresql+asyncpg://{self.db_user}:{self.db_password.get_secret_value()}@{self.db_host}:{self.db_port}/{self.db_name}" + + +class Settings(BaseSettings): + db_settings: DBSettings = DBSettings() + + +settings = Settings() diff --git a/lkeep/main.py b/lkeep/main.py index 1907c22..3cf304b 100644 --- a/lkeep/main.py +++ b/lkeep/main.py @@ -1,8 +1,8 @@ +import uvicorn from fastapi import FastAPI app = FastAPI() -@app.get("/") -async def index(): - return {"status": "It's ALIVE!"} +def start(): + uvicorn.run(app="lkeep.main:app", reload=True)