From b03404b2cc15dd6c053b0e5586caa6a242c1a50b Mon Sep 17 00:00:00 2001 From: kekskurse Date: Sun, 16 Jan 2022 12:27:54 +0100 Subject: [PATCH] Stuff --- main.go | 19 +++++++++++++++++-- notfall.tmpl | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 notfall.tmpl diff --git a/main.go b/main.go index ff2a4f6..35b4480 100644 --- a/main.go +++ b/main.go @@ -1,26 +1,41 @@ package main import ( + _ "embed" "encoding/json" "fmt" + "html/template" "net/http" ) var lastData interface{} +//go:embed notfall.tmpl +var templateContent []byte + + func main() { http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) { - var p interface{} + var p map[string]interface{} err := json.NewDecoder(request.Body).Decode(&p) if err != nil { writer.WriteHeader(http.StatusInternalServerError) return } + + if p["_type"] == "location"{ + lastData = p + } + fmt.Println(p) + + writer.Write([]byte("[]")) }) http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { - writer.Write([]byte("Hallo")) + templ := template.Must(template.New("page").Parse(string(templateContent))) + templ.Execute(writer, map[string]interface{}{ + }) }) http.ListenAndServe(":8080", nil) diff --git a/notfall.tmpl b/notfall.tmpl new file mode 100644 index 0000000..d1f488f --- /dev/null +++ b/notfall.tmpl @@ -0,0 +1,23 @@ + + + + + + + + +
+ + + \ No newline at end of file