diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/durpweb.iml b/.idea/durpweb.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/durpweb.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..79e9f63 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a2a0ced --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module gitlab.com/developerdurp/durpweb + +go 1.22.0 diff --git a/index.html b/index.html new file mode 100644 index 0000000..4be1715 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + + + +

Go and HTMX

+

{{.Message}}

+ +

Shows Current Time

+ + \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..d10cc4a --- /dev/null +++ b/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "html/template" + "net/http" + "time" +) + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + tmpl, err := template.ParseFiles("index.html") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + + data := struct { + Message string + }{ + Message: "Hello World", + } + + tmpl.Execute(w, data) + }) + + http.HandleFunc("/time", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("Current Time: " + time.Now().Format(time.RFC1123))) + }) + + fmt.Println("Started http server on port :8080") + http.ListenAndServe(":8080", nil) +}