This commit is contained in:
parent
123b48bc7c
commit
2fe93c77d7
1 changed files with 8 additions and 2 deletions
10
main.go
10
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"]
|
||||
|
|
Loading…
Reference in a new issue