Moge-Row commited on
Commit
fcbc7e3
·
1 Parent(s): 6861b68

restore main.go

Browse files
Files changed (1) hide show
  1. main.go +21 -22
main.go CHANGED
@@ -1,29 +1,28 @@
1
  package main
2
 
3
  import (
4
- "log"
5
- "net/http"
6
- "os"
 
 
 
7
  )
8
 
9
  func main() {
10
- // 1. Servir tu interfaz visual (HOI4)
11
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
12
- http.ServeFile(w, r, "index.html")
13
- })
14
-
15
- // 2. Ruta de salud para verificar que vive
16
- http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
17
- w.Write([]byte("Servidor Operativo"))
18
- })
19
-
20
- // Eliminamos la llamada a handler.HandleModels que está rompiendo el build
21
-
22
- port := os.Getenv("PORT")
23
- if port == "" { port = "7860" }
24
-
25
- log.Printf("Levantando proxy en puerto %s", port)
26
- if err := http.ListenAndServe(":" + port, nil); err != nil {
27
- log.Fatal(err)
28
- }
29
  }
 
1
  package main
2
 
3
  import (
4
+ "zai-proxy/internal/config"
5
+ "zai-proxy/internal/handler"
6
+ "zai-proxy/internal/logger"
7
+ "zai-proxy/internal/proxy"
8
+ "zai-proxy/internal/version"
9
+ "net/http"
10
  )
11
 
12
  func main() {
13
+ config.LoadConfig()
14
+ logger.InitLogger()
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("/v1/models", handler.HandleModels)
21
+ http.HandleFunc("/v1/chat/completions", handler.HandleChatCompletions)
22
+ http.HandleFunc("/v1/messages", handler.HandleMessages)
23
+ addr := ":" + config.Cfg.Port
24
+ logger.LogInfo("Server starting on %s", addr)
25
+ if err := http.ListenAndServe(addr, nil); err != nil {
26
+ logger.LogError("Server failed: %v", err)
27
+ }
 
 
 
 
28
  }