From 2269cc653577dffc58dba4ad5534583f28f224de Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 14 Jun 2021 11:48:39 +0200 Subject: Implement Frontend Status Display --- src/web.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/web.go') diff --git a/src/web.go b/src/web.go index 6515f47..206681d 100644 --- a/src/web.go +++ b/src/web.go @@ -37,6 +37,7 @@ func (server *WebServer) run() { router.Get("/", indexHandler) router.Get("/css/birdscan.css", cssHandler) router.Get("/js/birdscan.js", jsHandler) + router.Post("/api/state", stateHandler) router.Post("/api/single_picture", singlePictureHandler) log.Println("Binding to 'http://" + server.config.BindAddress + ":" + server.config.BindPort + "'") @@ -55,8 +56,12 @@ func jsHandler(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, fmt.Sprintf("%s/js/birdscan.js", APP_DATA)) } +func stateHandler(w http.ResponseWriter, r *http.Request) { + known_state := r.FormValue("known_state") + w.Write([]byte(fmt.Sprintf("%s", camera.GetStateOnChange(known_state)))) +} + func singlePictureHandler(w http.ResponseWriter, r *http.Request) { - log.Println("Received request for a single picture") camera.SendEvent("take_single_picture") fmt.Fprintf(w, http.StatusText(http.StatusOK)) } -- cgit v1.2.3-70-g09d2