21 lines
462 B
Go
21 lines
462 B
Go
|
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)
|
||
|
}
|