Add GET endpoint for states

This commit is contained in:
Backend IM Bot 2025-03-25 20:13:03 +01:00
parent 785d6bc0ff
commit d5e3b77542

17
endpoints/states.get.py Normal file
View File

@ -0,0 +1,17 @@
# Entity: State
from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session
from typing import List
from core.db.database import get_db
from core.models.state import State
from core.schemas.state import StateSchema
router = APIRouter()
@router.get("/states", status_code=200, response_model=List[StateSchema])
async def get_states(
db: Session = Depends(get_db)
):
states = db.query(State).all()
return states