From ba1bf0afde3b7806ea97bbf557b4b1ff9773b89b Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Wed, 9 Nov 2022 19:07:55 -0600 Subject: [PATCH] List of current work updates every second --- src/viddown.go | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/viddown.go b/src/viddown.go index 1744abe..0402589 100644 --- a/src/viddown.go +++ b/src/viddown.go @@ -20,6 +20,7 @@ package main import ( + "encoding/json" "io" "io/ioutil" "log" @@ -32,6 +33,7 @@ import ( ) const template = ` + Download @@ -41,7 +43,26 @@ const template = ` -

currentWork

+ +

` @@ -66,8 +87,17 @@ var opsc = make(chan ops) // handleRequest handles http requests func handleRequest(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodGet { - log.Print("New Get request") + if r.Method == http.MethodGet && r.URL.Path == "/currentwork" { + list, err := json.Marshal(currentWork) + if err != nil { + log.Panic(err) + } + + w.Write(list) + return + + } else if r.Method == http.MethodGet { + log.Print("New Get request: " + r.URL.Path) } else if r.Method == http.MethodPost { r.ParseForm() go func() {