三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

python FastAPI 最小服务

python FastAPI 最小服务

from fastapi import FastAPI, Request
import uvicorn

app = FastAPI()

@app.get("/health")
def health():
return {"ok": True}

@app.post("/echo")
async def echo(request: Request):
data = await request.json()
return data

if name == "main":
uvicorn.run(app, host="127.0.0.1", port=8000)

← 返回列表