Added auth
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"pool-stats/database"
|
||||
@@ -9,17 +8,12 @@ import (
|
||||
)
|
||||
|
||||
type IndexPageData struct {
|
||||
PageDataBase
|
||||
|
||||
Stats []models.TimeWindowHighShare
|
||||
}
|
||||
|
||||
func (ws *WebServer) IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.Must(ws.templates.Clone()).ParseFiles("templates/index.html")
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to parse template", 500)
|
||||
println("Error parsing template:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
tws := database.GetTimeWindowHighShares(ws.db)
|
||||
if tws == nil {
|
||||
http.Error(w, "Failed to load time window high shares", 500)
|
||||
@@ -30,9 +24,5 @@ func (ws *WebServer) IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
Stats: tws,
|
||||
}
|
||||
|
||||
if err := tmpl.ExecuteTemplate(w, "index.html", indexData); err != nil {
|
||||
http.Error(w, "Failed to render template", 500)
|
||||
println("Error rendering template:", err.Error())
|
||||
return
|
||||
}
|
||||
ws.renderTemplate(w, r, "templates/index.html", &indexData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user