Reorganize to fastapi template
This commit is contained in:
3
app/__init__.py
Normal file
3
app/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""`app` package for the project."""
|
||||
|
||||
__all__ = ["main"]
|
||||
3
app/api/__init__.py
Normal file
3
app/api/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""API package for routers."""
|
||||
|
||||
__all__ = ["health"]
|
||||
9
app/api/health.py
Normal file
9
app/api/health.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/health", tags=["health"])
|
||||
async def health_check():
|
||||
"""Minimal health endpoint."""
|
||||
return {"status": "ok"}
|
||||
3
app/core/__init__.py
Normal file
3
app/core/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""Core package for settings and helpers."""
|
||||
|
||||
__all__ = ["config"]
|
||||
8
app/core/config.py
Normal file
8
app/core/config.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
PROJECT_NAME: str = "home-automation-backend"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
18
app/main.py
Normal file
18
app/main.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.api.health import router as health_router
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(title=settings.PROJECT_NAME)
|
||||
app.include_router(health_router, prefix="/api")
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Welcome to the minimal FastAPI template"}
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user