20 lines
555 B
Python
20 lines
555 B
Python
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from pydantic import BaseModel
|
|
from typing import Optional
|
|
|
|
router = APIRouter()
|
|
|
|
class RequestBody(BaseModel):
|
|
data: str
|
|
|
|
@router.post("/api")
|
|
async def create_api(body: RequestBody):
|
|
"""
|
|
Create a simple API endpoint
|
|
"""
|
|
if not body.data:
|
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Data is required")
|
|
|
|
# Process the data and return a response
|
|
response_data = {"message": f"Received data: {body.data}"}
|
|
return response_data |