Stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kekskurse 2022-01-16 13:04:33 +01:00
parent 123b48bc7c
commit 2fe93c77d7
Signed by: kekskurse
GPG key ID: 728ACCB59341E7E4

10
main.go
View file

@ -3,7 +3,6 @@ package main
import ( import (
_ "embed" _ "embed"
"encoding/json" "encoding/json"
"fmt"
"html/template" "html/template"
"net/http" "net/http"
) )
@ -13,6 +12,9 @@ var lastData map[string]interface{}
//go:embed notfall.tmpl //go:embed notfall.tmpl
var templateContent []byte var templateContent []byte
var active = false
var getData = false
func main() { func main() {
http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) { http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) {
@ -27,7 +29,7 @@ func main() {
lastData = p lastData = p
} }
fmt.Println(p) getData = true
writer.Write([]byte("[]")) writer.Write([]byte("[]"))
}) })
@ -39,6 +41,10 @@ func main() {
}) })
http.HandleFunc("/json", func(writer http.ResponseWriter, request *http.Request) { 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 := make(map[string]interface{})
data["lat"] = lastData["lat"] data["lat"] = lastData["lat"]