Add GET endpoint for food
This commit is contained in:
parent
4d5a3b16ab
commit
c38bfac947
18
endpoints/food.get.py
Normal file
18
endpoints/food.get.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Entity: Food
|
||||
|
||||
from fastapi import APIRouter, Depends, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
from core.database import get_db
|
||||
from models.food import Food
|
||||
from schemas.food import FoodSchema
|
||||
from helpers.food_helpers import get_all_foods
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/food", status_code=200, response_model=List[FoodSchema])
|
||||
async def get_foods(
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
foods = get_all_foods(db)
|
||||
return foods
|
Loading…
x
Reference in New Issue
Block a user