Files
upscayl-server/main.go
2026-05-22 10:25:06 +08:00

43 lines
957 B
Go

package main
import (
"context"
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"trle5.xyz/upscayl-server/api"
"trle5.xyz/upscayl-server/configs"
"trle5.xyz/upscayl-server/task"
"trle5.xyz/upscayl-server/upscayl"
"trle5.xyz/upscayl-server/utils"
)
func main() {
configs.LoadConfig()
upscayl.CheckUpscayl()
r := chi.NewRouter()
r.Use(
utils.Recoverer,
middleware.Compress(5),
middleware.StripSlashes,
)
r.Get("/", api.GETAPIHandler)
r.Get("/models", api.GETModelsHandler)
r.Get("/tasks", api.GETTasksHandler)
r.Get("/tasks/{taskID}", api.GETTasksIDHandler)
r.Post("/tasks", api.POSTTasksHandler)
r.Options("/tasks", api.OPTIONSTasksHandler)
r.Handle("/output/*", http.StripPrefix("/output", http.FileServer(http.Dir(configs.OuputDir))))
go task.RunTasks(context.Background())
log.Println("upscayl-server started at http://localhost:7023")
log.Fatal(http.ListenAndServe(":7023", r))
}