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 (
|
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"]
|
||||||
|
|
Loading…
Reference in a new issue