from fastapi import FastAPI, Request import json app = FastAPI() # Define the default root route (GET request) for the homepage @app.get("/") async def root(): return {"message": "Welcome to the FastAPI Webhook Server!"} # Define a POST route that receives data and returns a success message @app.post("/webhook") async def webhook(request: Request): # Retrieve JSON data from the POST request data = await request.json() # Save data to a file or perform any other operation # Return a success message return {"status": "success", "message": "Data received successfully", "received_data": data}