// 作品 / 詳情

Project Delta

專案的簡介與使用的技術。

技術棧
pythonfastapi
SCREENSHOT_001.png

概述

Project Delta 是一個使用 FastAPI 建構的 Python 後端服務。它專注於 API 效能、資料驗證和乾淨架構。

主要功能

  • FastAPI — 高效能非同步 Python 框架
  • Pydantic — 執行時期資料驗證和序列化
  • SQLAlchemy — 支援非同步的 ORM

API 設計

API 遵循 RESTful 慣例,並自動生成 OpenAPI 文件:

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):
    name: str
    description: str | None = None
    price: float

@app.get("/items/{item_id}")
async def read_item(item_id: int):
    return {"item_id": item_id}

學到的東西

Python 的型別提示搭配 Pydantic 的驗證,讓建構穩健的 API 只需最少的樣板程式碼。FastAPI 的非同步支援對於高效處理並行請求至關重要。