35 lines
786 B
Python
35 lines
786 B
Python
from fastapi import APIRouter, HTTPException
|
|
import uuid
|
|
|
|
cats = [] # In-memory storage
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/cats")
|
|
async def create_cat(
|
|
name: str = "Whiskers",
|
|
breed: str = "Persian",
|
|
age: int = 2
|
|
):
|
|
"""Demo cat creation endpoint"""
|
|
if any(c["name"] == name for c in cats):
|
|
raise HTTPException(status_code=400, detail="Cat already exists")
|
|
|
|
cat_id = str(uuid.uuid4())
|
|
cats.append({
|
|
"id": cat_id,
|
|
"name": name,
|
|
"breed": breed,
|
|
"age": age,
|
|
"disabled": False
|
|
})
|
|
|
|
return {
|
|
"message": "Cat created successfully",
|
|
"cat_id": cat_id,
|
|
"name": name,
|
|
"next_steps": [
|
|
"Schedule vet checkup",
|
|
"Complete vaccination records"
|
|
]
|
|
} |