diff options
author | Julian T <julian@jtle.dk> | 2024-05-22 22:54:50 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2024-05-22 22:54:50 +0200 |
commit | dd11cf4ab199e5d53d03dc95b24007a12727ad70 (patch) | |
tree | 710f94ac775ac8e3d279f40638034b847516f0e3 /tidsreg.go | |
parent | 829cbaf2d0fe95abc9c65b1e34e209fc32952805 (diff) |
Start goprojekt istedet
Diffstat (limited to 'tidsreg.go')
-rw-r--r-- | tidsreg.go | 37 |
1 files changed, 37 insertions, 0 deletions
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)) +} |