test_deployment / app.py
tosanoob's picture
Update app.py
e5debfa verified
raw
history blame
467 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
import random
app = FastAPI()
class ResourceItem(BaseModel):
name: str
description: str | None = None
@app.get("/")
def read_root():
return {"Hello": "World!"}
@app.get("/random")
def return_random():
return {"Random number":int(random.random()*100)}
@app.post("/receive")
def return_received(item: ResourceItem):
return {'name':item.name,
'description':item.description}