Update code in endpoints/endpoint.get.py

This commit is contained in:
Backend IM Bot 2025-03-28 17:58:48 +00:00
parent 43fb2d85f0
commit 0d935f479f

View File

@ -0,0 +1,17 @@
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.fruit import Fruit
from schemas.fruit import FruitSchema, FruitCreate
from helpers.fruit_helpers import create_fruit
router = APIRouter()
@router.post("/fruits", status_code=201, response_model=FruitSchema)
async def create_fruit_entry(
fruit_data: FruitCreate,
db: Session = Depends(get_db)
):
new_fruit = create_fruit(db, fruit_data)
return new_fruit