From 4a37c11f7ae4d19de00dccc32131d0b4f20e0f5a Mon Sep 17 00:00:00 2001 From: Daniel Ledda Date: Thu, 5 Nov 2020 00:27:01 +0100 Subject: [PATCH] added visualisation --- climate-server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/climate-server.go b/climate-server.go index 5631f80..4f45837 100644 --- a/climate-server.go +++ b/climate-server.go @@ -36,6 +36,7 @@ func startServer() { port := "8001" r := mux.NewRouter() r.HandleFunc("/", showCharts).Methods("GET") + r.HandleFunc("/data/", sendData).Methods("GET") r.HandleFunc("/data/{count}", sendData).Methods("GET") r.HandleFunc("/", saveSnapshot).Methods("POST") 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) { - vars := mux.Vars(r) var count int64 = 50 - if vars["count"] != "" { + if vars := mux.Vars(r); vars["count"] != "" { newCount, err := strconv.ParseInt(vars["count"], 10, 0) if err != nil { sendInternalError(errors.New("bad snapshot count request"), w, r)