From afe3043715bb0b579b1f3f674cb51f217fc1adb1 Mon Sep 17 00:00:00 2001 From: aspergerli Date: Sun, 9 Feb 2025 11:29:04 +0100 Subject: [PATCH] Init --- go.mod | 3 ++ main.go | 74 ++++++++++++++++++++++++++++++++++++++++++++ static/style.css | 24 ++++++++++++++ templates/index.html | 16 ++++++++++ 4 files changed, 117 insertions(+) create mode 100644 go.mod create mode 100644 main.go create mode 100644 static/style.css create mode 100644 templates/index.html diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..15cb419 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.schreifuchs.ch/aspergerli/Hamlet-linktree + +go 1.23.4 diff --git a/main.go b/main.go new file mode 100644 index 0000000..ddf8b55 --- /dev/null +++ b/main.go @@ -0,0 +1,74 @@ +package main + +import ( + "html/template" + "log" + "net/http" +) + +type Link struct { + Text string + Href string +} +type Data struct { + Links []Link +} + +var data = Data{ + Links: []Link{ + { + Text: "", + Href: "http://immich.dihei", + }, + { + Text: "git", + Href: "http://git.dihei", + }, + { + Text: "git", + Href: "http://git.dihei", + }, + { + Text: "git", + Href: "http://git.dihei", + }, + { + Text: "git", + Href: "http://git.dihei", + }, + { + Text: "git", + Href: "http://git.dihei", + }, + }, +} + +// Handle the homepage request +func homePage(w http.ResponseWriter, r *http.Request) { + // Parse the HTML template + tmpl, err := template.ParseFiles("templates/index.html") + if err != nil { + log.Fatal("Error parsing template: ", err) + } + + // Execute the template and render it + err = tmpl.Execute(w, data) + if err != nil { + log.Fatal("Error executing template: ", err) + } +} + +func main() { + // Serve static files (CSS) + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + + // Handle the homepage + http.HandleFunc("/", homePage) + + // Start the server + log.Println("Server started on http://localhost:8080") + err := http.ListenAndServe(":8080", nil) + if err != nil { + log.Fatal("Error starting server: ", err) + } +} diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..ddd99d9 --- /dev/null +++ b/static/style.css @@ -0,0 +1,24 @@ +body { + background-color: #292929 +} +a { + font-family: serif; +font-size: 1.5em; +padding: 0.5em; +} +a:link { + color: rgb(202, 202, 202); +} +a:hover { + color: aqua; +} +a:visited { + color: rgb(146, 143, 111); +} +div { + display: flex; + flex-flow: column; +} +a:active { + color: cornflowerblue; +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..43d2b63 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,16 @@ + + + + + + Document + + + +
+ {{range .Links}} + {{.Text}} + {{end}} +
+ + \ No newline at end of file