開始使用免費開始

加入簡單的健康檢查端點

你想在你的應用程式中加入一個簡單的健康檢查端點。

本練習屬於課程

使用 FastAPI 將 AI 佈署到生產環境

檢視課程

練習說明

  • 在健康檢查的典型路徑新增一個 GET 端點。
  • 回傳 "OK" 的狀態。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

from fastapi import FastAPI

app = FastAPI()

# Create health check endpoint
@app.get("____")
async def get_health():
    # Return status OK
    return {"status": "____"}
編輯並執行程式碼