ravib / app.py
Ravib189's picture
jj
afd0a42 verified
raw
history blame contribute delete
566 Bytes
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
class GreetingResponse(BaseModel):
Hello: str
app = FastAPI()
@app.get("/", response_model=GreetingResponse)
async def greet_json() -> GreetingResponse:
try:
return GreetingResponse(Hello="World!")
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/health")
async def health_check():
return {"status": "healthy"}
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def greet_json():
return {"Hello": "World!"}