from fastapi import FastAPI, Request app = FastAPI() @app.post("/") async def log_json(request: Request): try: # Parse the JSON body from the request json_body = await request.json() # Log the JSON payload to the console print("Received JSON payload:", json_body) # Respond with a success message return {"status": "success", "message": "JSON payload logged successfully"} except Exception as e: # Handle cases where the request body is not valid JSON print("Failed to parse JSON payload:", e) return {"status": "error", "message": "Invalid JSON payload"}, 400 :contentReference[oaicite:2]{index=2}