court/handlers/webui.go

21 lines
462 B
Go
Raw Normal View History

2024-03-28 11:29:32 +01:00
package handlers
import (
//"fmt"
"court/models"
"html/template"
"net/http"
)
func Webui(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles("templates/index.html"))
err, courts := DB.GetAllUrls()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("Internal server error"))
return
}
data := models.PageData{PageTitle: "Court - a URL Shortener", Courts: *courts}
tmpl.Execute(w, data)
}