gitgraph term and svg generation complete

This commit is contained in:
2022-06-19 15:53:12 -04:00
parent 64e1a55168
commit c29a30e687
7 changed files with 127 additions and 1 deletions

41
bin/server/svg-server.go Normal file
View File

@@ -0,0 +1,41 @@
package main
import (
"math/rand"
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/taigrr/gitgraph/svg"
)
type DayCount [366]int
func init() {
rand.Seed(time.Now().UnixMilli())
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/weekly.svg", func(w http.ResponseWriter, r *http.Request) {
freq := []int{}
for i := 0; i < 7; i++ {
freq = append(freq, rand.Int())
}
w.Header().Add("Content-Type", "text/html")
svg := svg.GetWeekSVG(freq)
svg.WriteTo(w)
})
r.HandleFunc("/yearly.svg", func(w http.ResponseWriter, r *http.Request) {
freq := []int{}
for i := 0; i < 365; i++ {
freq = append(freq, rand.Int())
}
svg := svg.GetYearSVG(freq)
w.Header().Add("Content-Type", "text/html")
svg.WriteTo(w)
})
http.ListenAndServe(":8080", r)
}