這是一個在 Fly.io 上部署 FastAPI 應用程式的範例專案。
關於本專案的完整設定與部署教學,請參考以下文章:
- Python 3.8+
- pip
-
複製專案:
git clone https://github.com/andy6804tw/fastapi-fly-demo.git cd fastapi-fly-demo -
安裝依賴套件:
pip install -r requirements.txt
-
啟動本地伺服器:
uvicorn main:app --reload
應用程式將會在
http://127.0.0.1:8000上運行。
- 安裝 flyctl
- 註冊並登入 Fly.io 帳號
-
登入 Fly.io CLI:
fly auth login
-
啟動並部署應用程式:
fly launch
fly launch會自動偵測專案並建立fly.toml設定檔,接著進行部署。 -
(可選) 未來若有更新,僅需執行:
fly deploy
GET /: 返回一個歡迎訊息。GET /health: 返回應用程式的健康狀態。