From 6319a9dc2913f005c735835ac4b46301d6885c64 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 3 Nov 2025 08:29:33 -0300 Subject: outros routes --- api/routes/measures.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'api/routes/measures.py') diff --git a/api/routes/measures.py b/api/routes/measures.py index e69de29..f98c203 100644 --- a/api/routes/measures.py +++ b/api/routes/measures.py @@ -0,0 +1,25 @@ +from fastapi import APIRouter +from sqlalchemy import select +from ..database import SessionLocal +from ..models import Measure + +router = APIRouter( + prefix='/measures', + tags=['measures'] +) + +@router.get('/') +async def get_measures(): + dc = {'measures': []} + session = SessionLocal() + stmt = select(Measure) + measures = session.execute(stmt) + for measure in measures.scalars(): + mem = { + 'id': measure.id, + 'name': measure.name, + 'unit_code': measure.unit_code + } + dc['measures'].append(mem) + dc['size'] = len(dc['measures']) + return dc -- cgit v1.2.3