Add GET endpoint for states
This commit is contained in:
parent
785d6bc0ff
commit
d5e3b77542
17
endpoints/states.get.py
Normal file
17
endpoints/states.get.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user