Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
class Ping(BaseModel):
|
| 7 |
+
message: str
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
def root():
|
| 11 |
+
return {"status": "space is alive 🚀"}
|
| 12 |
+
|
| 13 |
+
@app.post("/echo")
|
| 14 |
+
def echo(data: Ping):
|
| 15 |
+
return {
|
| 16 |
+
"you_sent": data.message,
|
| 17 |
+
"working": True
|
| 18 |
+
}
|