sathish2352 commited on
Commit
e32387b
·
verified ·
1 Parent(s): b1a4b49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,11 +1,11 @@
1
- # app.py
2
- from fastapi import FastAPI, Request
3
- from fastapi.responses import JSONResponse
4
 
5
- app = FastAPI()
6
 
7
- @app.post("/echo")
8
- async def echo(request: Request):
9
- data = await request.json()
10
- return {"you_sent": data}
11
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
 
3
 
4
+ app = FastAPI(title="Echo API", description="API that returns the input text unchanged")
5
 
6
+ class TextInput(BaseModel):
7
+ text: str
 
 
8
 
9
+ @app.post("/echo", response_model=TextInput)
10
+ async def echo_text(input: TextInput):
11
+ return {"text": input.text}