https://github.com/1010code/fastapi-fly-demo
https://github.com/1010code/fastapi-fly-demo
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/1010code/fastapi-fly-demo
- Owner: 1010code
- Created: 2025-11-30T08:59:44.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-01T12:07:42.000Z (7 months ago)
- Last Synced: 2025-12-04T00:36:34.364Z (7 months ago)
- Language: Dockerfile
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI on Fly.io 部署範例
這是一個在 Fly.io 上部署 FastAPI 應用程式的範例專案。
## 操作說明
關於本專案的完整設定與部署教學,請參考以下文章:
[教學文章:將 FastAPI 部署到 Render](https://andy6804tw.github.io/2025/11/30/deploy-fly-on-render/)
## 本地端開發
### 需求
* Python 3.8+
* pip
### 安裝與啟動
1. 複製專案:
```bash
git clone https://github.com/andy6804tw/fastapi-fly-demo.git
cd fastapi-fly-demo
```
2. 安裝依賴套件:
```bash
pip install -r requirements.txt
```
3. 啟動本地伺服器:
```bash
uvicorn main:app --reload
```
應用程式將會在 `http://127.0.0.1:8000` 上運行。
## 部署到 Fly.io
### 需求
* 安裝 [flyctl](https://fly.io/docs/hands-on/install-flyctl/)
* 註冊並登入 Fly.io 帳號
### 部署步驟
1. 登入 Fly.io CLI:
```bash
fly auth login
```
2. 啟動並部署應用程式:
```bash
fly launch
```
> `fly launch` 會自動偵測專案並建立 `fly.toml` 設定檔,接著進行部署。
3. (可選) 未來若有更新,僅需執行:
```bash
fly deploy
```
## API 端點
* `GET /`: 返回一個歡迎訊息。
* `GET /health`: 返回應用程式的健康狀態。