27 lines
669 B
Go
27 lines
669 B
Go
package web
|
|
|
|
import (
|
|
// "fmt"
|
|
"html/template"
|
|
"net/http"
|
|
|
|
"github.com/aceberg/WatchYourLAN/internal/check"
|
|
"github.com/aceberg/WatchYourLAN/internal/db"
|
|
"github.com/aceberg/WatchYourLAN/internal/models"
|
|
)
|
|
|
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|
var guiData models.GuiData
|
|
|
|
AllHosts = db.Select(AppConfig.DbPath)
|
|
|
|
guiData.Config = AppConfig
|
|
guiData.Hosts = AllHosts
|
|
guiData.Icon = Icon
|
|
|
|
tmpl, _ := template.ParseFiles(TemplPath+"index.html", TemplPath+"header.html", TemplPath+"footer.html")
|
|
err := tmpl.ExecuteTemplate(w, "header", guiData)
|
|
check.IfError(err)
|
|
err = tmpl.ExecuteTemplate(w, "index", guiData)
|
|
check.IfError(err)
|
|
}
|