Init
This commit is contained in:
commit
afe3043715
3
go.mod
Normal file
3
go.mod
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module git.schreifuchs.ch/aspergerli/Hamlet-linktree
|
||||||
|
|
||||||
|
go 1.23.4
|
74
main.go
Normal file
74
main.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
24
static/style.css
Normal file
24
static/style.css
Normal file
@ -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;
|
||||||
|
}
|
16
templates/index.html
Normal file
16
templates/index.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
{{range .Links}}
|
||||||
|
<a href="{{.Href}}">{{.Text}}</a>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user