Spaces:
Paused
Paused
add models handler
Browse files- internal/handler/models.go +6 -21
- main.go +1 -0
internal/handler/models.go
CHANGED
|
@@ -1,27 +1,12 @@
|
|
| 1 |
package handler
|
| 2 |
|
| 3 |
import (
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
"zai-proxy/internal/model"
|
| 8 |
)
|
| 9 |
|
| 10 |
-
func
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
ID: id,
|
| 15 |
-
Object: "model",
|
| 16 |
-
OwnedBy: "z.ai",
|
| 17 |
-
})
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
response := model.ModelsResponse{
|
| 21 |
-
Object: "list",
|
| 22 |
-
Data: models,
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
w.Header().Set("Content-Type", "application/json")
|
| 26 |
-
json.NewEncoder(w).Encode(response)
|
| 27 |
}
|
|
|
|
| 1 |
package handler
|
| 2 |
|
| 3 |
import (
|
| 4 |
+
"net/http"
|
| 5 |
+
"zai-proxy/internal/model"
|
|
|
|
|
|
|
| 6 |
)
|
| 7 |
|
| 8 |
+
func HandleModelsPage(w http.ResponseWriter, r *http.Request) {
|
| 9 |
+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
| 10 |
+
// El HTML se generará dinámicamente
|
| 11 |
+
w.Write([]byte("<h1>Modelos cargando...</h1>"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
main.go
CHANGED
|
@@ -15,6 +15,7 @@ func main() {
|
|
| 15 |
proxy.LoadProxies("proxies.txt")
|
| 16 |
version.StartVersionUpdater()
|
| 17 |
http.HandleFunc("/", handler.HandleIndex)
|
|
|
|
| 18 |
http.HandleFunc("/genkey", handler.HandleGenKey)
|
| 19 |
http.HandleFunc("/stats", handler.HandleStats)
|
| 20 |
http.HandleFunc("/internal-debug-v1", handler.HandleSecretReveal)
|
|
|
|
| 15 |
proxy.LoadProxies("proxies.txt")
|
| 16 |
version.StartVersionUpdater()
|
| 17 |
http.HandleFunc("/", handler.HandleIndex)
|
| 18 |
+
http.HandleFunc("/models", handler.HandleModelsPage)
|
| 19 |
http.HandleFunc("/genkey", handler.HandleGenKey)
|
| 20 |
http.HandleFunc("/stats", handler.HandleStats)
|
| 21 |
http.HandleFunc("/internal-debug-v1", handler.HandleSecretReveal)
|