ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

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)

返回列表