added visualisation

This commit is contained in:
Daniel Ledda
2020-11-05 00:27:01 +01:00
parent 1bd5020180
commit 4a37c11f7a

View File

@@ -36,6 +36,7 @@ func startServer() {
port := "8001" port := "8001"
r := mux.NewRouter() r := mux.NewRouter()
r.HandleFunc("/", showCharts).Methods("GET") r.HandleFunc("/", showCharts).Methods("GET")
r.HandleFunc("/data/", sendData).Methods("GET")
r.HandleFunc("/data/{count}", sendData).Methods("GET") r.HandleFunc("/data/{count}", sendData).Methods("GET")
r.HandleFunc("/", saveSnapshot).Methods("POST") r.HandleFunc("/", saveSnapshot).Methods("POST")
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("static/")))) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
@@ -49,9 +50,8 @@ func showCharts(w http.ResponseWriter, r *http.Request) {
} }
func sendData(w http.ResponseWriter, r *http.Request) { func sendData(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
var count int64 = 50 var count int64 = 50
if vars["count"] != "" { if vars := mux.Vars(r); vars["count"] != "" {
newCount, err := strconv.ParseInt(vars["count"], 10, 0) newCount, err := strconv.ParseInt(vars["count"], 10, 0)
if err != nil { if err != nil {
sendInternalError(errors.New("bad snapshot count request"), w, r) sendInternalError(errors.New("bad snapshot count request"), w, r)