Update code in endpoints/leran.post.py
This commit is contained in:
parent
8c9aa9426f
commit
d31ef49145
@ -0,0 +1,35 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
import uuid
|
||||
|
||||
books = [] # In-memory storage
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/learn")
|
||||
async def generate_book(
|
||||
title: str = "Sample Book",
|
||||
author: str = "Default Author",
|
||||
genre: str = "Fiction"
|
||||
):
|
||||
"""Demo book generation endpoint"""
|
||||
if any(b["title"] == title for b in books):
|
||||
raise HTTPException(status_code=400, detail="Book already exists")
|
||||
|
||||
book_id = str(uuid.uuid4())
|
||||
books.append({
|
||||
"id": book_id,
|
||||
"title": title,
|
||||
"author": author,
|
||||
"genre": genre,
|
||||
"disabled": False
|
||||
})
|
||||
|
||||
return {
|
||||
"message": "Book created successfully",
|
||||
"book_id": book_id,
|
||||
"title": title,
|
||||
"next_steps": [
|
||||
"Add chapters (demo)",
|
||||
"Complete book details"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user