39 lines
869 B
Go
39 lines
869 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"aroll/handlers"
|
|
"aroll/store"
|
|
"aroll/ws"
|
|
)
|
|
|
|
func main() {
|
|
st, err := store.New()
|
|
if err != nil {
|
|
log.Fatalf("store: %v", err)
|
|
}
|
|
log.Println("Temp storage ready")
|
|
|
|
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.HandleFunc("/zoom", handlers.ZoomHandler(hub))
|
|
mux.Handle("/download/", http.StripPrefix("/download/", handlers.DownloadHandler(st)))
|
|
|
|
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))
|
|
}
|