diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-06-14 11:48:39 +0200 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-06-14 11:48:39 +0200 |
commit | 2269cc653577dffc58dba4ad5534583f28f224de (patch) | |
tree | 31d99e3bc92a49ca87e5dac363481fed982128f9 /src/web.go | |
parent | 9d5a2f9870e52bfc0fe6db8c27981f29d91dcb55 (diff) | |
download | birdscan-2269cc653577dffc58dba4ad5534583f28f224de.tar birdscan-2269cc653577dffc58dba4ad5534583f28f224de.tar.zst birdscan-2269cc653577dffc58dba4ad5534583f28f224de.zip |
Implement Frontend Status Display
Diffstat (limited to 'src/web.go')
-rw-r--r-- | src/web.go | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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)) } |