feat: добавлен запуск FastAPI с использованием uvicorn и создание файла настроек

- Добавлена поддержка утилиты uvicorn для запуска приложения FastAPI.
- Создан новый модуль `settings.py` в пакете `core`, содержащий настройки базы данных.
This commit is contained in:
proDream 2025-01-10 05:07:38 +04:00
parent a8272f71c2
commit b541fdf57a
3 changed files with 27 additions and 3 deletions

0
lkeep/core/__init__.py Normal file
View File

24
lkeep/core/settings.py Normal file
View File

@ -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()

View File

@ -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)