Update page contents
This commit is contained in:
23
main.go
23
main.go
@@ -19,8 +19,9 @@ var hjemTemplate string
|
||||
var port = flag.Int("p", 1437, "set the port for hjem to use")
|
||||
|
||||
type HjemData struct {
|
||||
OS string
|
||||
Email string
|
||||
OS string
|
||||
Email string
|
||||
Timezone string
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -67,12 +68,26 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
user_tz := "UTC"
|
||||
if tz := os.Getenv("TZ"); tz != "" {
|
||||
user_tz = tz
|
||||
} else if data, err := os.ReadFile("/etc/timezone"); err == nil {
|
||||
if tz := strings.TrimSpace(string(data)); tz != "" {
|
||||
user_tz = tz
|
||||
}
|
||||
} else if path, err := os.Readlink("/etc/localtime"); err == nil {
|
||||
user_tz = filepath.Join(
|
||||
filepath.Base(filepath.Dir(path)),
|
||||
filepath.Base(path))
|
||||
}
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
err := t.ExecuteTemplate(w, "hjem", HjemData{
|
||||
OS: user_os,
|
||||
Email: user_email,
|
||||
OS: user_os,
|
||||
Email: user_email,
|
||||
Timezone: user_tz,
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user