summaryrefslogtreecommitdiff
path: root/api/routes
diff options
context:
space:
mode:
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.'}
+