feat: add favicon.ico and gate model write APIs by env flag

- Generate and serve real /favicon.ico from static assets
- Update HTML to use /favicon.ico
- Add ENABLE_MODEL_RW_API setting (default: false)
- Disable POST/DELETE model endpoints by default
- Hide write endpoints from OpenAPI when disabled
- Return 404 for write endpoints when disabled
- Update env.example with ENABLE_MODEL_RW_API documentation
- Update README and PRD with R/W API policy and remote compose notes
- Add tests to verify write endpoints are disabled by default
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-24 19:35:24 +02:00
parent 893376dc14
commit 32b1130632
9 changed files with 69 additions and 9 deletions
+20 -3
View File
@@ -85,6 +85,7 @@ OLLAMA_TIMEOUT=30
API_HOST=0.0.0.0
API_PORT=8000
API_WORKERS=4
ENABLE_MODEL_RW_API=false
# CORS Configuration
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
@@ -105,6 +106,7 @@ ENVIRONMENT=development
| `API_HOST` | `0.0.0.0` | Host su cui esporre l'API |
| `API_PORT` | `8000` | Porta dell'API |
| `API_WORKERS` | `4` | Worker processes |
| `ENABLE_MODEL_RW_API` | `false` | Abilita endpoint `POST/DELETE` sui modelli |
| `CORS_ORIGINS` | `http://localhost:3000` | Origini CORS consentite |
| `LOG_LEVEL` | `INFO` | Livello di logging |
| `ENVIRONMENT` | `development` | Ambiente (development/production) |
@@ -151,6 +153,21 @@ GET /api/v1/models/{model_name}
GET /api/v1/health
```
#### Endpoint R/W modelli (opzionali)
Per impostazione predefinita gli endpoint di scrittura sono **disabilitati** e non disponibili.
```bash
POST /api/v1/models/{model_name}/pull
DELETE /api/v1/models/{model_name}
```
Per abilitarli, imposta nel file `.env`:
```env
ENABLE_MODEL_RW_API=true
```
**Risposta:**
```json
@@ -215,16 +232,16 @@ docker compose restart llm-monitor
### Container sempre acceso
Il container Ollama rimarrà in esecuzione fino al suo arresto manuale:
Il container `llm-monitor` rimarrà in esecuzione fino al suo arresto manuale:
```bash
# Fermare
docker compose stop ollama
docker compose stop llm-monitor
# oppure
docker stop llm-monitor
# Riavviare
docker compose start ollama
docker compose start llm-monitor
# oppure
docker start llm-monitor
```