summaryrefslogtreecommitdiff
path: root/api/routes
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-11-03 09:21:37 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-11-03 09:21:37 -0300
commitde7df7c80b2b0a2d2efe9c97463003771bc58bfa (patch)
tree5cdab1bd685a6478f9c339fa01a5242199ff62e3 /api/routes
parent6319a9dc2913f005c735835ac4b46301d6885c64 (diff)
post location
Diffstat (limited to 'api/routes')
-rw-r--r--api/routes/locations.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/api/routes/locations.py b/api/routes/locations.py
index 5050cef..a2e4dc6 100644
--- a/api/routes/locations.py
+++ b/api/routes/locations.py
@@ -3,6 +3,8 @@ from sqlalchemy import select
from ..database import SessionLocal
from ..models import Location
+from pydantic import BaseModel
+
router = APIRouter(
prefix='/locations',
tags=['locations']
@@ -25,3 +27,18 @@ async def get_locations():
dc['size'] = len(dc['locations'])
return dc
+
+class PostLocation(BaseModel):
+ street: str
+ avenue: str
+ zip_code:str
+
+@router.post('/')
+async def create_location(location: PostLocation):
+ session = SessionLocal()
+ session.begin()
+ session.add(Location(street=location.street, avenue=location.avenue, zip_code=location.zip_code))
+ session.commit()
+ session.close()
+ return {'msg': 'Localização adicionada com sucesso.'}
+