การ Deploy AI สู่ Production ด้วย FastAPI
Matt Eckerle
Software and Data Engineering Leader


✓ Python เบื้องต้น: ฟังก์ชัน คลาส โมดูล และโครงสร้างข้อมูล

✓ Python เบื้องต้น: ฟังก์ชัน คลาส โมดูล และโครงสร้างข้อมูล
✓ แนวคิด HTTP & REST API

✓ Python เบื้องต้น: ฟังก์ชัน คลาส โมดูล และโครงสร้างข้อมูล
✓ แนวคิด HTTP & REST API
✓ การใช้ FastAPI framework
✓ พื้นฐาน Machine Learning


GET https://example.com/?item_id=1

from fastapi import FastAPI
app = FastAPI()
@app.get("/item/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id}
{item_id} คือ path parameterint) สำหรับการตรวจสอบอัตโนมัติ
POST https://example.com

from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() db = {}class Item(BaseModel): name: str price: float@app.post("/items", status_code=201)def create_item(item: Item): db[item.name] = item.model_dump() return {"message": f"Created {item.name}"}
@app.post สำหรับ POST endpoint

from fastapi import FastAPI, HTTPException app = FastAPI() @app.get("/item/{item_id}") async def read_item(item_id: int): if item_id == 4242: #An invalid order number raise HTTPException(status_code=404, detail="Item not found") return {"item_id": item_id}@app.post("/items") async def create_item(item: Item): # Simulating item creation return {"message": f"Created {item.name}"}, 201
การ Deploy AI สู่ Production ด้วย FastAPI