ss / app.py
srinuksv's picture
Update app.py
3d0cead verified
raw
history blame
700 Bytes
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
with open("received_data.json", "w") as f:
json.dump(data, f)
# Return a success message
return {"status": "success", "message": "Data received successfully", "received_data": data}