From 2fe93c77d714dbe4617e024c86ffbf9e380e61e0 Mon Sep 17 00:00:00 2001 From: kekskurse Date: Sun, 16 Jan 2022 13:04:33 +0100 Subject: [PATCH] Stuff --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4181f81..87426d3 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( _ "embed" "encoding/json" - "fmt" "html/template" "net/http" ) @@ -13,6 +12,9 @@ var lastData map[string]interface{} //go:embed notfall.tmpl var templateContent []byte +var active = false +var getData = false + func main() { http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) { @@ -27,7 +29,7 @@ func main() { lastData = p } - fmt.Println(p) + getData = true writer.Write([]byte("[]")) }) @@ -39,6 +41,10 @@ func main() { }) http.HandleFunc("/json", func(writer http.ResponseWriter, request *http.Request) { + if getData == false || active == false { + writer.WriteHeader(http.StatusInternalServerError) + return + } data := make(map[string]interface{}) data["lat"] = lastData["lat"]