package main import ( "log" "net/http" "os" "aroll/handlers" "aroll/store" "aroll/ws" ) func main() { redisAddr := "localhost:6379" if addr := os.Getenv("REDIS_ADDR"); addr != "" { redisAddr = addr } st, err := store.New(redisAddr) if err != nil { log.Fatalf("redis: %v", err) } log.Printf("Connected to Redis at %s", redisAddr) hub := ws.NewHub() go hub.Run() mux := http.NewServeMux() mux.HandleFunc("/ws", handlers.WSHandler(hub)) mux.HandleFunc("/upload", handlers.UploadHandler(st)) mux.HandleFunc("/analyze", handlers.AnalyzeHandler(st, hub)) mux.HandleFunc("/export", handlers.ExportHandler(st, hub)) mux.Handle("/download/", http.StripPrefix("/download/", handlers.DownloadHandler(st))) // Serve the React build in production if _, err := os.Stat("frontend/dist"); err == nil { mux.Handle("/", http.FileServer(http.Dir("frontend/dist"))) } log.Println("Listening on http://localhost:8080") log.Fatal(http.ListenAndServe(":8080", mux)) }