From dd11cf4ab199e5d53d03dc95b24007a12727ad70 Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 22 May 2024 22:54:50 +0200 Subject: Start goprojekt istedet --- tidsreg.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tidsreg.go (limited to 'tidsreg.go') diff --git a/tidsreg.go b/tidsreg.go new file mode 100644 index 0000000..9821672 --- /dev/null +++ b/tidsreg.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "text/template" +) + +type Server struct { + template *template.Template +} + +func (c *Server) rootHandle(w http.ResponseWriter, r * http.Request) { + tmpl, err := template.ParseFiles("templates/index.html") + if err != nil { + log.Println(err) + return + } + tmpl.Execute(w, nil) +} + +func main() { + fmt.Println("Hello world!") + + template, err := template.ParseFS(templates, "templates/*.html") + if err != nil { + log.Fatal(err) + } + + s := Server { + template: template, + } + + http.HandleFunc("/", s.rootHandle) + log.Fatal(http.ListenAndServe(":8080", nil)) +} -- cgit v1.2.3