14 lines
476 B
Python
14 lines
476 B
Python
from fastapi import APIRouter, HTTPException, status
|
|
from typing import Dict, Any
|
|
from helpers.fruit_helpers import create_fruit
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/create-fruit", status_code=status.HTTP_201_CREATED)
|
|
async def create_new_fruit(fruit_data: Dict[str, Any]):
|
|
"""Create a new fruit entry"""
|
|
try:
|
|
new_fruit = create_fruit(fruit_data)
|
|
return new_fruit
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e)) |