from fastapi import FastAPI, Request | |
import json | |
app = FastAPI() | |
# Define the default root route (GET request) for the homepage | |
async def root(): | |
return {"message": "Welcome to the FastAPI Webhook Server!"} | |
# Define a POST route that receives data and returns a success message | |
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} | |