index — crispy-website @ 493a0d106556e0980f94cfbf0a00069c32fa029e

My personal homepage (very crispy)

music.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
package main

import (
	"net/http"
	"text/template"
)

type musicData struct {
	Releases []musicItem
	Spending float32
}

func musicHandler(w http.ResponseWriter, r *http.Request) {
	results := loadMusic()
	spending := getSpending()
	tmpl := template.Must(template.ParseFiles("templates/music.html"))

	data := musicData{Releases: results, Spending: spending}

	err := tmpl.Execute(w, data)
	if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
    }

}