Add GET endpoint for /endpint
This commit is contained in:
parent
ba29d7e14e
commit
260a3b78fe
@ -0,0 +1,18 @@
|
|||||||
|
# Entity: Color
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from typing import List
|
||||||
|
from core.database import get_db
|
||||||
|
from models.color import Color
|
||||||
|
from schemas.color import ColorSchema
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.get("/endpoint", response_model=List[ColorSchema], status_code=200)
|
||||||
|
async def get_colors(
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
"""Get all colors"""
|
||||||
|
colors = db.query(Color).all()
|
||||||
|
return colors
|
Loading…
x
Reference in New Issue
Block a user