commit eb633ae
chld
·
2026-04-24 14:40:51 +0000 UTC
parent eb633ae
init
A
srv.go
+35,
-0
1@@ -0,0 +1,35 @@
2+package main
3+
4+import (
5+ "fmt"
6+ "net/http"
7+ "math/rand"
8+ "time"
9+ "os"
10+)
11+
12+func handler(w http.ResponseWriter, r *http.Request) {
13+ var fortune = [...]string{"so good", "its chld", "who you know and hate", "fuck", "cholodu", "codeberg.org"}
14+ rand.Seed(time.Now().UnixNano())
15+
16+ f, _ := os.ReadFile("./style.css")
17+ fmt.Fprintf(w, "<style>\n"+string(f)+"</style>\n")
18+
19+ fmt.Fprintf(w, "<html><body><center>\n")
20+ fmt.Fprintf(w, "<p>%s</p>\n", fortune[rand.Intn(len(fortune))])
21+ fmt.Fprintf(w, "<a href=https://codeberg.org>berg</a> | <a href=https://sr.ht/~chld/>srht</a>")
22+ fmt.Fprintf(w, "</html></body></center>")
23+}
24+
25+func main() {
26+ port:="8080"
27+
28+
29+ http.Handle("./", http.StripPrefix("./", http.FileServer(http.Dir("."))))
30+ http.HandleFunc("/", handler)
31+
32+ fmt.Println("srv started at localhost:"+port)
33+ if err := http.ListenAndServe(":"+port, nil); err != nil {
34+ fmt.Println("error with srv:", err)
35+ }
36+}
+3,
-0
1@@ -0,0 +1,3 @@
2+body {
3+ font-family: monospace;
4+}