fix some stuff
confusedbread confuseddbread@gmail.com
Wed, 02 Jul 2025 20:26:30 +0200
2 files changed,
16 insertions(+),
9 deletions(-)
M
backend/main.go
→
backend/main.go
@@ -4,7 +4,6 @@ import (
"fmt" "log" "net/http" - "reflect" ) type PlayingInfo struct {@@ -15,7 +14,7 @@ recordingUrl string
coverUrl string } -func main() { +func getInfo() PlayingInfo { playingInfo := PlayingInfo{} playingNow, err := getPlayingNow("confuseddbread")@@ -36,13 +35,11 @@
coverArt, err := getCover(metadata.ReleaseMbid) playingInfo.coverUrl = coverArt.Images[0].Image - v := reflect.ValueOf(playingInfo) - k := v.Type() - for i := range v.NumField() { - log.Printf("%s: %s\n", k.Field(i).Name, v.Field(i)) - } + return playingInfo +} - http.HandleFunc("/", playingInfo.handler) +func main() { + http.HandleFunc("/", handler) log.Println("http://localhost:8080") log.Fatal(http.ListenAndServe(":8080", nil)) }
M
backend/net.go
→
backend/net.go
@@ -2,10 +2,20 @@ package main
import ( "fmt" + "log" "net/http" + "reflect" ) -func (playingInfo *PlayingInfo) handler(w http.ResponseWriter, r *http.Request) { +func handler(w http.ResponseWriter, r *http.Request) { + playingInfo := getInfo() + + v := reflect.ValueOf(playingInfo) + k := v.Type() + for i := range v.NumField() { + log.Printf("%s: %s\n", k.Field(i).Name, v.Field(i)) + } + fmt.Fprintf( w, "<p>%s</p><p>%s</p><p>%s</p><a href=\"%s\"><img src=\"%s\"></a>",