Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
from fastapi.responses import JSONResponse
|
| 4 |
|
| 5 |
-
app = FastAPI()
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 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}
|