watchyourlan/internal/web/webgui.go
2022-12-26 23:30:49 +07:00

47 lines
1.1 KiB
Go

package web
import (
// "embed"
"log"
"net/http"
"github.com/aceberg/WatchYourLAN/internal/check"
"github.com/aceberg/WatchYourLAN/internal/models"
)
var (
// AppConfig - app config
AppConfig models.Conf
// TemplPath - path to html templates
TemplPath string
)
// var AllHosts []Host
////go:embed templates/*
// var TemplHTML embed.FS
// Gui - start web GUI
func Gui(appConfig models.Conf) {
TemplPath = "../../internal/web/templates/"
AppConfig = appConfig
address := AppConfig.GuiIP + ":" + AppConfig.GuiPort
log.Println("=================================== ")
log.Printf("Web GUI at http://%s", address)
log.Println("=================================== ")
http.HandleFunc("/", index)
http.HandleFunc("/home/", index)
// http.HandleFunc("/offline/", offline)
// http.HandleFunc("/online/", online)
// http.HandleFunc("/search_hosts/", search_hosts)
// http.HandleFunc("/sort_hosts/", sort_hosts)
// http.HandleFunc("/theme/", theme)
// http.HandleFunc("/update_host/", update_host)
err := http.ListenAndServe(address, nil)
check.IfError(err)
}