test: Test api on raspberry
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from pydantic import BaseModel
|
||||||
|
import time
|
||||||
|
|
||||||
|
app = FastAPI(title="Test API (no serial)")
|
||||||
|
|
||||||
|
class Echo(BaseModel):
|
||||||
|
msg: str
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
def health():
|
||||||
|
return {"ok": True, "ts": time.time()}
|
||||||
|
|
||||||
|
@app.get("/ping")
|
||||||
|
def ping():
|
||||||
|
return {"pong": True}
|
||||||
|
|
||||||
|
@app.post("/echo")
|
||||||
|
def echo(body: Echo):
|
||||||
|
return {"echo": body.msg}
|
||||||
Reference in New Issue
Block a user