Upload 204 files
Browse files- .gitattributes +1 -0
- DEPLOYMENT_GUIDE.md +215 -269
- Dockerfile +2 -2
- __pycache__/ai_models.cpython-313.pyc +0 -0
- __pycache__/api_server_extended.cpython-313.pyc +3 -0
- __pycache__/config.cpython-313.pyc +0 -0
- __pycache__/hf_unified_server.cpython-313.pyc +2 -2
- api_server_extended.py +3 -3
- app.py +22 -15
.gitattributes
CHANGED
|
@@ -41,3 +41,4 @@ final/__pycache__/hf_unified_server.cpython-313.pyc filter=lfs diff=lfs merge=lf
|
|
| 41 |
final/data/crypto_monitor.db filter=lfs diff=lfs merge=lfs -text
|
| 42 |
app/final/__pycache__/hf_unified_server.cpython-313.pyc filter=lfs diff=lfs merge=lfs -text
|
| 43 |
app/final/data/crypto_monitor.db filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 41 |
final/data/crypto_monitor.db filter=lfs diff=lfs merge=lfs -text
|
| 42 |
app/final/__pycache__/hf_unified_server.cpython-313.pyc filter=lfs diff=lfs merge=lfs -text
|
| 43 |
app/final/data/crypto_monitor.db filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
__pycache__/api_server_extended.cpython-313.pyc filter=lfs diff=lfs merge=lfs -text
|
DEPLOYMENT_GUIDE.md
CHANGED
|
@@ -1,269 +1,215 @@
|
|
| 1 |
-
# 🚀 Deployment Guide -
|
| 2 |
-
|
| 3 |
-
##
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
###
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
###
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
```
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
```
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
###
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
###
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
@limiter.limit("10/minute")
|
| 217 |
-
async def analyze_sentiment(...):
|
| 218 |
-
pass
|
| 219 |
-
```
|
| 220 |
-
|
| 221 |
-
### 3. Model Optimization
|
| 222 |
-
```python
|
| 223 |
-
# Use smaller models for faster inference
|
| 224 |
-
# quantization برای کاهش حجم
|
| 225 |
-
from transformers import AutoModelForSequenceClassification
|
| 226 |
-
model = AutoModelForSequenceClassification.from_pretrained(
|
| 227 |
-
"model_id",
|
| 228 |
-
torch_dtype=torch.float16 # Half precision
|
| 229 |
-
)
|
| 230 |
-
```
|
| 231 |
-
|
| 232 |
-
## Monitoring
|
| 233 |
-
|
| 234 |
-
### Logs
|
| 235 |
-
```bash
|
| 236 |
-
# Docker logs
|
| 237 |
-
docker logs -f crypto-hub
|
| 238 |
-
|
| 239 |
-
# HuggingFace Space logs
|
| 240 |
-
# قابل مشاهده در dashboard Space
|
| 241 |
-
```
|
| 242 |
-
|
| 243 |
-
### Metrics
|
| 244 |
-
```bash
|
| 245 |
-
# Health endpoint برای monitoring
|
| 246 |
-
curl http://your-space.hf.space/api/health
|
| 247 |
-
|
| 248 |
-
# Response:
|
| 249 |
-
{
|
| 250 |
-
"status": "healthy",
|
| 251 |
-
"uptime": 3600,
|
| 252 |
-
"models_loaded": 2,
|
| 253 |
-
"datasets_available": 14
|
| 254 |
-
}
|
| 255 |
-
```
|
| 256 |
-
|
| 257 |
-
## Support
|
| 258 |
-
|
| 259 |
-
- **Documentation**: README_HF_INTEGRATION.md
|
| 260 |
-
- **Issues**: Check logs first
|
| 261 |
-
- **Performance**: Use HF Space with GPU for heavy models
|
| 262 |
-
|
| 263 |
-
## نکات مهم
|
| 264 |
-
|
| 265 |
-
1. ⚠️ **HF_TOKEN**: حتماً در secrets تنظیم کنید
|
| 266 |
-
2. 🔥 **Models**: اولین بار کند است (downloading)
|
| 267 |
-
3. 💾 **Cache**: مدلها cache میشوند
|
| 268 |
-
4. 🚀 **WebSocket**: برای real-time updates
|
| 269 |
-
5. 📊 **Dashboard**: در `/` قابل دسترسی
|
|
|
|
| 1 |
+
# 🚀 Deployment Guide - Modern Crypto Intelligence Hub
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
This guide explains how to deploy the **new modern UI** with sidebar navigation, glassmorphism theme, and visual sentiment analysis.
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## 🎯 What Changed
|
| 9 |
+
|
| 10 |
+
### ✨ New Features
|
| 11 |
+
1. **Vertical Sidebar Navigation** - Replaces top tab bar, collapses to hamburger menu on mobile
|
| 12 |
+
2. **Inline SVG Icons** - Replaced FontAwesome with crisp SVG icons (Heroicons/Feather style)
|
| 13 |
+
3. **Glassmorphism Theme** - Deep dark theme with blur effects and neon accents
|
| 14 |
+
4. **Modern News Cards** - Time-ago formatting, sorted by latest, image placeholders
|
| 15 |
+
5. **Visual Sentiment Analysis**:
|
| 16 |
+
- Gauge/speedometer charts showing sentiment scores
|
| 17 |
+
- Animated trend arrows (green up for bullish, red down for bearish)
|
| 18 |
+
- Confidence bars with shimmer effects
|
| 19 |
+
6. **Fixed Dashboard** - Loads immediately on page load
|
| 20 |
+
|
| 21 |
+
### 📁 Files Updated
|
| 22 |
+
- `index.html` - New sidebar structure with SVG icons
|
| 23 |
+
- `static/css/main.css` - Glassmorphism styles, news cards, sentiment visualizations
|
| 24 |
+
- `static/js/app.js` - Visual sentiment functions, time-ago formatting, improved news display
|
| 25 |
+
- `app.py` - Forces FastAPI mode
|
| 26 |
+
- `Dockerfile` - Updated to run FastAPI directly
|
| 27 |
+
- `README.md` - Added Hugging Face Space metadata
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## 🚀 Deployment Options
|
| 32 |
+
|
| 33 |
+
### Option 1: Hugging Face Spaces (Recommended)
|
| 34 |
+
|
| 35 |
+
The app is configured to run on Hugging Face Spaces with Docker SDK.
|
| 36 |
+
|
| 37 |
+
**Steps:**
|
| 38 |
+
1. Push all files to your Hugging Face Space repository
|
| 39 |
+
2. Ensure `README.md` has the correct metadata (already added):
|
| 40 |
+
```yaml
|
| 41 |
+
---
|
| 42 |
+
title: Crypto Intelligence Hub
|
| 43 |
+
emoji: 🚀
|
| 44 |
+
sdk: docker
|
| 45 |
+
app_port: 7860
|
| 46 |
+
---
|
| 47 |
+
```
|
| 48 |
+
3. The Space will automatically build and deploy using the `Dockerfile`
|
| 49 |
+
4. The Dockerfile is configured to run: `uvicorn api_server_extended:app`
|
| 50 |
+
|
| 51 |
+
**Environment Variables (Optional):**
|
| 52 |
+
- `USE_FASTAPI_HTML=true` (default in Dockerfile)
|
| 53 |
+
- `PORT=7860` (default)
|
| 54 |
+
|
| 55 |
+
### Option 2: Local Development
|
| 56 |
+
|
| 57 |
+
**Using PowerShell:**
|
| 58 |
+
```powershell
|
| 59 |
+
# Navigate to project directory
|
| 60 |
+
cd "path\to\crypto-dt-source-main"
|
| 61 |
+
|
| 62 |
+
# Install dependencies
|
| 63 |
+
pip install -r requirements.txt
|
| 64 |
+
|
| 65 |
+
# Run FastAPI server directly
|
| 66 |
+
python -m uvicorn api_server_extended:app --host 0.0.0.0 --port 7860 --reload
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
**Using the startup script:**
|
| 70 |
+
```bash
|
| 71 |
+
# Make executable (Linux/Mac)
|
| 72 |
+
chmod +x start_app.sh
|
| 73 |
+
./start_app.sh
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### Option 3: Docker
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
# Build image
|
| 80 |
+
docker build -t crypto-hub .
|
| 81 |
+
|
| 82 |
+
# Run container
|
| 83 |
+
docker run -p 7860:7860 crypto-hub
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 🔧 Troubleshooting
|
| 89 |
+
|
| 90 |
+
### Issue: Gradio UI shows instead of modern HTML UI
|
| 91 |
+
|
| 92 |
+
**Solution:**
|
| 93 |
+
The app should automatically use FastAPI mode. If you see Gradio:
|
| 94 |
+
|
| 95 |
+
1. Check environment variables:
|
| 96 |
+
```bash
|
| 97 |
+
export USE_FASTAPI_HTML=true
|
| 98 |
+
export USE_GRADIO=false
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
2. Run FastAPI directly:
|
| 102 |
+
```bash
|
| 103 |
+
python -m uvicorn api_server_extended:app --host 0.0.0.0 --port 7860
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
3. Verify `Dockerfile` CMD:
|
| 107 |
+
```dockerfile
|
| 108 |
+
CMD ["python", "-m", "uvicorn", "api_server_extended:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
### Issue: Static files not loading
|
| 112 |
+
|
| 113 |
+
**Solution:**
|
| 114 |
+
1. Verify `static/` folder exists with `css/` and `js/` subdirectories
|
| 115 |
+
2. Check `api_server_extended.py` mounts static files:
|
| 116 |
+
```python
|
| 117 |
+
app.mount("/static", StaticFiles(directory=str(static_path)), name="static")
|
| 118 |
+
```
|
| 119 |
+
3. Access files at: `http://localhost:7860/static/css/main.css`
|
| 120 |
+
|
| 121 |
+
### Issue: News not loading
|
| 122 |
+
|
| 123 |
+
**Solution:**
|
| 124 |
+
1. Click "Fetch Latest News" button to pull from CryptoCompare API
|
| 125 |
+
2. Check database: `data/database/crypto_monitor.db`
|
| 126 |
+
3. Verify `/api/news` endpoint returns data
|
| 127 |
+
|
| 128 |
+
### Issue: Sentiment analysis not working
|
| 129 |
+
|
| 130 |
+
**Solution:**
|
| 131 |
+
1. Check Hugging Face models are loaded: Visit `/api/models/status`
|
| 132 |
+
2. Models use fallback lexical analysis if HF models unavailable
|
| 133 |
+
3. Check logs for model loading errors
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## 📊 API Endpoints
|
| 138 |
+
|
| 139 |
+
The FastAPI server provides these endpoints:
|
| 140 |
+
|
| 141 |
+
- `/` - Main dashboard (HTML UI)
|
| 142 |
+
- `/api/resources` - System resources summary
|
| 143 |
+
- `/api/market` - Cryptocurrency market data
|
| 144 |
+
- `/api/news` - News articles
|
| 145 |
+
- `/api/news/fetch` - Fetch latest news from CryptoCompare
|
| 146 |
+
- `/api/sentiment/analyze` - Sentiment analysis
|
| 147 |
+
- `/api/models/status` - AI models status
|
| 148 |
+
- `/api/models/list` - Available models
|
| 149 |
+
- `/docs` - Interactive API documentation
|
| 150 |
+
- `/health` - Health check
|
| 151 |
+
|
| 152 |
+
---
|
| 153 |
+
|
| 154 |
+
## 🎨 UI Features
|
| 155 |
+
|
| 156 |
+
### Sidebar Navigation
|
| 157 |
+
- **Desktop:** Fixed sidebar on left, 280px wide
|
| 158 |
+
- **Mobile:** Collapsible hamburger menu with overlay
|
| 159 |
+
- **Icons:** Inline SVG for crisp rendering at any size
|
| 160 |
+
|
| 161 |
+
### News Feed
|
| 162 |
+
- **Time-Ago:** Shows "2 hours ago" instead of dates
|
| 163 |
+
- **Sorting:** Latest news first
|
| 164 |
+
- **Cards:** Modern card design with image placeholders
|
| 165 |
+
- **Symbols:** Related crypto symbols as badges
|
| 166 |
+
|
| 167 |
+
### Sentiment Analysis
|
| 168 |
+
- **Gauge Chart:** Semi-circular gauge (0-100 scale)
|
| 169 |
+
- **Trend Arrows:** Animated SVG arrows indicating direction
|
| 170 |
+
- **Confidence Bar:** Progress bar with shimmer animation
|
| 171 |
+
- **Color Coding:**
|
| 172 |
+
- Green (Bullish/Positive)
|
| 173 |
+
- Red (Bearish/Negative)
|
| 174 |
+
- Yellow (Neutral)
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
## 🔒 Security Notes
|
| 179 |
+
|
| 180 |
+
1. **API Keys:** Store in environment variables, not in code
|
| 181 |
+
2. **CORS:** Configured for all origins in development (restrict in production)
|
| 182 |
+
3. **Rate Limiting:** Consider adding rate limiting for production
|
| 183 |
+
4. **Database:** SQLite for development, consider PostgreSQL for production
|
| 184 |
+
|
| 185 |
+
---
|
| 186 |
+
|
| 187 |
+
## 📝 Next Steps
|
| 188 |
+
|
| 189 |
+
1. **Deploy to Hugging Face Spaces**
|
| 190 |
+
2. **Test all features:**
|
| 191 |
+
- Dashboard loads
|
| 192 |
+
- News fetches and displays
|
| 193 |
+
- Sentiment analysis works
|
| 194 |
+
- Sidebar navigation functions
|
| 195 |
+
- Mobile responsive design
|
| 196 |
+
3. **Monitor logs** for any errors
|
| 197 |
+
4. **Customize:**
|
| 198 |
+
- Add your own API keys
|
| 199 |
+
- Adjust theme colors in `main.css`
|
| 200 |
+
- Add more trading pairs in `trading_pairs.txt`
|
| 201 |
+
|
| 202 |
+
---
|
| 203 |
+
|
| 204 |
+
## 🆘 Support
|
| 205 |
+
|
| 206 |
+
If you encounter issues:
|
| 207 |
+
1. Check browser console for JavaScript errors
|
| 208 |
+
2. Check server logs for Python errors
|
| 209 |
+
3. Verify all dependencies are installed
|
| 210 |
+
4. Ensure `index.html`, `main.css`, and `app.js` are in correct locations
|
| 211 |
+
|
| 212 |
+
---
|
| 213 |
+
|
| 214 |
+
**Enjoy your modern Crypto Intelligence Hub! 🚀**
|
| 215 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
|
@@ -33,5 +33,5 @@ ENV USE_GRADIO=false
|
|
| 33 |
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
-
# Run the application
|
| 37 |
-
CMD ["python", "app.
|
|
|
|
| 33 |
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Run the FastAPI application directly for modern HTML UI
|
| 37 |
+
CMD ["python", "-m", "uvicorn", "api_server_extended:app", "--host", "0.0.0.0", "--port", "7860"]
|
__pycache__/ai_models.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/ai_models.cpython-313.pyc and b/__pycache__/ai_models.cpython-313.pyc differ
|
|
|
__pycache__/api_server_extended.cpython-313.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25c377b2d08d563fce48c8cd8fda8166287ce225d1a7469a288227d1ab6b42e3
|
| 3 |
+
size 146136
|
__pycache__/config.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/config.cpython-313.pyc and b/__pycache__/config.cpython-313.pyc differ
|
|
|
__pycache__/hf_unified_server.cpython-313.pyc
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:daa8c605bec5a177f1583e7c65957cbe2b6d7b9345bd816a4776b3f43e1d0b34
|
| 3 |
+
size 457
|
api_server_extended.py
CHANGED
|
@@ -655,15 +655,15 @@ try:
|
|
| 655 |
static_path = WORKSPACE_ROOT / "static"
|
| 656 |
if static_path.exists():
|
| 657 |
app.mount("/static", StaticFiles(directory=str(static_path)), name="static")
|
| 658 |
-
|
| 659 |
else:
|
| 660 |
# Create static directories if they don't exist
|
| 661 |
static_path.mkdir(parents=True, exist_ok=True)
|
| 662 |
(static_path / "css").mkdir(exist_ok=True)
|
| 663 |
(static_path / "js").mkdir(exist_ok=True)
|
| 664 |
-
|
| 665 |
except Exception as e:
|
| 666 |
-
|
| 667 |
|
| 668 |
# Serve trading pairs file
|
| 669 |
@app.get("/trading_pairs.txt")
|
|
|
|
| 655 |
static_path = WORKSPACE_ROOT / "static"
|
| 656 |
if static_path.exists():
|
| 657 |
app.mount("/static", StaticFiles(directory=str(static_path)), name="static")
|
| 658 |
+
logger.info(f"Mounted static files from {static_path}")
|
| 659 |
else:
|
| 660 |
# Create static directories if they don't exist
|
| 661 |
static_path.mkdir(parents=True, exist_ok=True)
|
| 662 |
(static_path / "css").mkdir(exist_ok=True)
|
| 663 |
(static_path / "js").mkdir(exist_ok=True)
|
| 664 |
+
logger.info(f"Created static directories at {static_path}")
|
| 665 |
except Exception as e:
|
| 666 |
+
logger.warning(f"Could not mount static files: {e}")
|
| 667 |
|
| 668 |
# Serve trading pairs file
|
| 669 |
@app.get("/trading_pairs.txt")
|
app.py
CHANGED
|
@@ -768,11 +768,12 @@ if __name__ == "__main__":
|
|
| 768 |
logger.info(f"🤖 Models available: {len(hub.get_available_models())}")
|
| 769 |
logger.info(f"🔌 FastAPI available: {FASTAPI_AVAILABLE}")
|
| 770 |
|
| 771 |
-
#
|
| 772 |
-
#
|
| 773 |
if FASTAPI_AVAILABLE:
|
| 774 |
# Run FastAPI with HTML interface (preferred for HF Spaces)
|
| 775 |
logger.info("🌐 Starting FastAPI server with HTML interface...")
|
|
|
|
| 776 |
import uvicorn
|
| 777 |
port = int(os.getenv("PORT", "7860"))
|
| 778 |
uvicorn.run(
|
|
@@ -781,17 +782,23 @@ if __name__ == "__main__":
|
|
| 781 |
port=port,
|
| 782 |
log_level="info"
|
| 783 |
)
|
| 784 |
-
elif USE_GRADIO:
|
| 785 |
-
# Run Gradio interface (fallback)
|
| 786 |
-
logger.info("🎨 Starting Gradio interface...")
|
| 787 |
-
app = create_gradio_interface()
|
| 788 |
-
app.launch(
|
| 789 |
-
server_name="0.0.0.0",
|
| 790 |
-
server_port=int(os.getenv("GRADIO_SERVER_PORT", "7860")),
|
| 791 |
-
share=False,
|
| 792 |
-
show_error=True
|
| 793 |
-
)
|
| 794 |
else:
|
| 795 |
-
#
|
| 796 |
-
logger.
|
| 797 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 768 |
logger.info(f"🤖 Models available: {len(hub.get_available_models())}")
|
| 769 |
logger.info(f"🔌 FastAPI available: {FASTAPI_AVAILABLE}")
|
| 770 |
|
| 771 |
+
# FORCE FastAPI+HTML mode for modern UI
|
| 772 |
+
# Always prefer FastAPI with HTML interface over Gradio
|
| 773 |
if FASTAPI_AVAILABLE:
|
| 774 |
# Run FastAPI with HTML interface (preferred for HF Spaces)
|
| 775 |
logger.info("🌐 Starting FastAPI server with HTML interface...")
|
| 776 |
+
logger.info("✨ Modern UI with Sidebar Navigation enabled")
|
| 777 |
import uvicorn
|
| 778 |
port = int(os.getenv("PORT", "7860"))
|
| 779 |
uvicorn.run(
|
|
|
|
| 782 |
port=port,
|
| 783 |
log_level="info"
|
| 784 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
else:
|
| 786 |
+
# Fallback: Try to import and run api_server_extended directly
|
| 787 |
+
logger.warning("⚠️ FastAPI not imported via normal path, trying direct import...")
|
| 788 |
+
try:
|
| 789 |
+
import sys
|
| 790 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 791 |
+
from api_server_extended import app as fastapi_app_direct
|
| 792 |
+
import uvicorn
|
| 793 |
+
port = int(os.getenv("PORT", "7860"))
|
| 794 |
+
logger.info("🌐 Starting FastAPI server (direct import)...")
|
| 795 |
+
uvicorn.run(
|
| 796 |
+
fastapi_app_direct,
|
| 797 |
+
host="0.0.0.0",
|
| 798 |
+
port=port,
|
| 799 |
+
log_level="info"
|
| 800 |
+
)
|
| 801 |
+
except Exception as e:
|
| 802 |
+
logger.error(f"❌ Could not start FastAPI: {e}")
|
| 803 |
+
logger.error("❌ Modern UI unavailable. Please check api_server_extended.py")
|
| 804 |
+
raise SystemExit(1)
|