From 0fb10b86a8c17108b99c9216a908a009f2ef98fe Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 11:45:39 -0500 Subject: [PATCH] Add POST endpoint for /rivers --- endpoints/rivers.post.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 endpoints/rivers.post.py diff --git a/endpoints/rivers.post.py b/endpoints/rivers.post.py new file mode 100644 index 0000000..487dbbe --- /dev/null +++ b/endpoints/rivers.post.py @@ -0,0 +1,26 @@ +# Entity: Lake + +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +from app.api.db.database import get_db +# You'll need to add correct model and schema imports + +router = APIRouter() + +@router.post("/rivers", response_model=List[LakeSchema]) +async def get_lakes_in_paris( + city: str = "Paris", + db: Session = Depends(get_db) +): + """ + Get a list of lakes in the specified city. + + By default, it returns lakes in Paris. + """ + lakes = db.query(Lake).filter(Lake.city == city).all() + + if not lakes: + raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, + detail=f"No lakes found in {city}") + + return lakes \ No newline at end of file