kenichi miyata
commited on
Commit
·
d1ffbde
1
Parent(s):
3705eb2
🚀 Add GitHub Actions auto-deploy workflow and FastAPI Debug Toolbar
Browse files✅ Added features:
- GitHub Actions workflow for auto-deployment to HF Spaces
- FastAPI Debug Toolbar with Laravel-style UI
- Content-Length issue fixed for streaming responses
- SQLAlchemy query monitoring
- Real-time performance tracking
- Interactive toolbar (click to expand)
🤖 Ready for automatic deployment on push to main branch
- README.md +67 -23
- app_new.py +38 -0
README.md
CHANGED
@@ -1,27 +1,71 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
-
sdk:
|
7 |
-
sdk_version: 4.29.0
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
|
|
|
|
10 |
---
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: FastAPI Django Main Live
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
|
|
|
|
7 |
pinned: false
|
8 |
+
license: mit
|
9 |
+
app_port: 8004
|
10 |
---
|
11 |
|
12 |
+
# FastAPI Debug Toolbar - Hugging Face Spaces
|
13 |
+
|
14 |
+
🚀 **Laravel風デバッグツールバー for FastAPI**
|
15 |
+
|
16 |
+
## 🌟 特徴
|
17 |
+
|
18 |
+
- ✅ **GitHub Actions自動デプロイ**
|
19 |
+
- 🔧 **Content-Length問題修正済み**
|
20 |
+
- 📊 **SQLAlchemy クエリ監視**
|
21 |
+
- ⚡ **リアルタイムパフォーマンス測定**
|
22 |
+
- 🎨 **Laravel風美しいUI**
|
23 |
+
- 🌐 **Hugging Face Spaces完全対応**
|
24 |
+
|
25 |
+
## 🚀 アクセス
|
26 |
+
|
27 |
+
デバッグツールバー付きのページにアクセスして、画面下部のバーをクリックしてください:
|
28 |
+
|
29 |
+
- `/demo` - 完全デモページ
|
30 |
+
- `/simple` - シンプルテスト
|
31 |
+
- `/users` - データベースクエリテスト
|
32 |
+
|
33 |
+
## 🔄 自動デプロイ
|
34 |
+
|
35 |
+
このスペースはGitHub Actionsで自動更新されます:
|
36 |
+
- `main`ブランチへのプッシュで自動デプロイ
|
37 |
+
- 手動実行も可能
|
38 |
+
- デバッグツールバーの最新版を常に反映
|
39 |
+
|
40 |
+
## 📡 最終更新
|
41 |
+
|
42 |
+
Last deployed: 2025-06-08 13:50:00 UTC
|
43 |
+
|
44 |
+
## 🛠️ GitHub Actions設定手順
|
45 |
+
|
46 |
+
1. **GitHubリポジトリを作成**
|
47 |
+
```
|
48 |
+
リポジトリ名: fastapi_django_main_live
|
49 |
+
公開設定: Public
|
50 |
+
説明: FastAPI Debug Toolbar with auto-deployment
|
51 |
+
```
|
52 |
+
|
53 |
+
2. **HF_TOKENシークレットを設定**
|
54 |
+
- GitHubリポジトリ → Settings → Secrets and variables → Actions
|
55 |
+
- New repository secret で `HF_TOKEN` を追加
|
56 |
+
- Hugging Face token を値として設定
|
57 |
+
|
58 |
+
3. **自動デプロイの実行**
|
59 |
+
- mainブランチにプッシュすると自動デプロイ開始
|
60 |
+
- Actions タブで進行状況を確認
|
61 |
+
|
62 |
+
## 📊 デバッグツールバー機能
|
63 |
+
|
64 |
+
- ✅ Laravel-style UI with gradients
|
65 |
+
- ✅ SQLAlchemy query monitoring
|
66 |
+
- ✅ Real-time performance tracking
|
67 |
+
- ✅ Streaming response (Content-Length fixed)
|
68 |
+
- ✅ Interactive toolbar (click to expand)
|
69 |
+
- ✅ Request/Response analysis
|
70 |
+
- ✅ Database query profiling
|
71 |
+
- ✅ Memory and CPU usage tracking
|
app_new.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
"""
|
3 |
+
Hugging Face Spaces FastAPI Debug Toolbar
|
4 |
+
GitHub Actions自動デプロイ版
|
5 |
+
"""
|
6 |
+
import os
|
7 |
+
import sys
|
8 |
+
|
9 |
+
# codespaces_debug.py から app をインポート
|
10 |
+
try:
|
11 |
+
from codespaces_debug import app
|
12 |
+
print("✅ FastAPI Debug Toolbar loaded successfully")
|
13 |
+
except ImportError as e:
|
14 |
+
print(f"❌ Failed to import codespaces_debug: {e}")
|
15 |
+
# フォールバック用の簡単なFastAPIアプリ
|
16 |
+
from fastapi import FastAPI
|
17 |
+
from fastapi.responses import HTMLResponse
|
18 |
+
|
19 |
+
app = FastAPI(title="FastAPI Debug Toolbar - Error")
|
20 |
+
|
21 |
+
@app.get("/")
|
22 |
+
async def error_page():
|
23 |
+
return HTMLResponse("""
|
24 |
+
<!DOCTYPE html>
|
25 |
+
<html>
|
26 |
+
<head><title>Debug Toolbar Error</title></head>
|
27 |
+
<body>
|
28 |
+
<h1>❌ Error Loading Debug Toolbar</h1>
|
29 |
+
<p>Failed to load codespaces_debug.py</p>
|
30 |
+
<p>Check the logs for more details.</p>
|
31 |
+
</body>
|
32 |
+
</html>
|
33 |
+
""")
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
import uvicorn
|
37 |
+
port = int(os.environ.get("PORT", 8004))
|
38 |
+
uvicorn.run(app, host="0.0.0.0", port=port)
|