2025-03-19 09:54:46 +00:00

60 lines
1.7 KiB
Python

from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
from typing import List, Optional
from core.database import fake_users_db
router = APIRouter()
class BakingInstructions(BaseModel):
recipe_name: str
temperature: int
baking_time: int
ingredients: List[str]
steps: List[str]
notes: Optional[str] = None
@router.post("/api/v1/endpoint")
async def bake_code(
instructions: BakingInstructions
):
"""Create baking instructions for coding concepts"""
if instructions.temperature < 0 or instructions.temperature > 500:
raise HTTPException(
status_code=400,
detail="Temperature must be between 0 and 500 degrees"
)
if instructions.baking_time < 1:
raise HTTPException(
status_code=400,
detail="Baking time must be at least 1 minute"
)
recipe_id = len(fake_users_db) + 1
recipe = {
"id": recipe_id,
"recipe_name": instructions.recipe_name,
"temperature": instructions.temperature,
"baking_time": instructions.baking_time,
"ingredients": instructions.ingredients,
"steps": instructions.steps,
"notes": instructions.notes
}
fake_users_db[recipe_id] = recipe
return {
"message": "Recipe created successfully",
"recipe": recipe,
"tips": [
"Make sure to follow each step carefully",
"Check understanding before moving to next step",
"Practice makes perfect!"
],
"metadata": {
"difficulty_level": "beginner",
"estimated_completion_time": f"{instructions.baking_time} minutes"
}
}