Ravib189 commited on
Commit
afd0a42
·
verified ·
1 Parent(s): 7e56afd
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,7 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
 
3
  app = FastAPI()
4
 
5
  @app.get("/")
6
  def greet_json():
7
- return {"Jesus Loves You!"}
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from pydantic import BaseModel
3
+
4
+ class GreetingResponse(BaseModel):
5
+ Hello: str
6
+
7
+ app = FastAPI()
8
+
9
+ @app.get("/", response_model=GreetingResponse)
10
+ async def greet_json() -> GreetingResponse:
11
+ try:
12
+ return GreetingResponse(Hello="World!")
13
+ except Exception as e:
14
+ raise HTTPException(status_code=500, detail=str(e))
15
+
16
+ @app.get("/health")
17
+ async def health_check():
18
+ return {"status": "healthy"}
19
  from fastapi import FastAPI
20
 
21
  app = FastAPI()
22
 
23
  @app.get("/")
24
  def greet_json():
25
+ return {"Hello": "World!"}