From 500faf8ed4032ee0722efea565734c179e983a70 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 19 Mar 2025 12:58:27 +0000 Subject: [PATCH] Update code in endpoints/api/v1/endpoint.post.py --- endpoints/api/v1/endpoint.post.py | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 endpoints/api/v1/endpoint.post.py diff --git a/endpoints/api/v1/endpoint.post.py b/endpoints/api/v1/endpoint.post.py new file mode 100644 index 0000000..63fd529 --- /dev/null +++ b/endpoints/api/v1/endpoint.post.py @@ -0,0 +1,43 @@ +from fastapi import APIRouter, Depends, HTTPException +from core.database import fake_users_db +import uuid + +router = APIRouter() + +@router.post("/gdt-book") +async def create_gdt_book( + title: str, + author: str, + description: str = "", + category: str = "general" +): + """Create a new GDT book entry""" + book_id = str(uuid.uuid4()) + + if title.strip() == "": + raise HTTPException(status_code=400, detail="Title cannot be empty") + + new_book = { + "id": book_id, + "title": title, + "author": author, + "description": description, + "category": category, + "created_at": "2024-01-01T00:00:00Z", # Demo timestamp + "status": "active" + } + + # Store in demo database + if "books" not in fake_users_db: + fake_users_db["books"] = {} + fake_users_db["books"][book_id] = new_book + + return { + "message": "GDT book created successfully", + "book_id": book_id, + "data": new_book, + "metadata": { + "created_timestamp": "2024-01-01T00:00:00Z", + "version": "1.0" + } + } \ No newline at end of file