File size: 328 Bytes
67c10a3
1dc9545
 
 
 
 
67c10a3
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from fastapi import FastAPI ,Request

app = FastAPI()

@app.get("/")
def greet_json():
    return {"Hello": "World!"}

@app.post("/")
def greet_json(request: Request):
    data = request.json()  # Get the JSON body of the request
    name = data.get("name", "World")  # Extract "name" from the request
    return {"Hello": name}