Files
0908_--USER--/user_api.txt
2025-09-08 16:21:07 +08:00

22 lines
827 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

請產生一支可直接執行的 Flask API 伺服器,需求:
- 使用 mysql.connector 連線
資料庫資訊:
DB_HOST = mysql.theaken.com
DB_PORT = 33306
DB_NAME = db_A027
DB_USER = A027
DB_PASSWORD = E1CelfxqlKoj
TABLE = pizzas
- 路由:
- GET /v1/pizzas支援 ?min_age、?max_age、?page、?limit要多回傳 {meta}
- GET /v1/pizzas/<id>:找不到回 404
- POST /v1/pizzas接收 JSON {name,email,age},欄位驗證,成功回 201 並回新資料
- PATCH /v1/pizzas/<id>可更新任一欄位name/email/age成功回 200 回更新後資料
- DELETE /v1/pizzas/<id>:成功回 204
- 所有寫入請用參數化查詢避免 SQL 注入
- 統一格式 { status,code,message,data }
- 統一錯誤格式 {status:"error", code, message}
- 啟用 CORS允許本機前端