เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

เพิ่ม health check endpoint แบบง่าย

เพิ่ม health check endpoint แบบง่ายให้กับแอปของคุณ

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การ Deploy AI สู่ Production ด้วย FastAPI

ดูคอร์ส

คำแนะนำการฝึกหัด

  • เพิ่ม GET endpoint ที่ตำแหน่งทั่วไปสำหรับ health check
  • Return ค่า status เป็น "OK"

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

from fastapi import FastAPI

app = FastAPI()

# Create health check endpoint
@app.get("____")
async def get_health():
    # Return status OK
    return {"status": "____"}
แก้ไขและรันโค้ด