diff --git a/main.go b/main.go index 71dea07..0507d7a 100644 --- a/main.go +++ b/main.go @@ -81,7 +81,8 @@ func main() { r := mux.NewRouter() r.HandleFunc("/", HomeHandler) r.HandleFunc("/fetch", FetchHandler) - r.HandleFunc("/fetch/info/{id}", FetchInfoHandler) + r.HandleFunc("/fetch/info", FetchInfoHandler) + r.HandleFunc("/fetch/info/{id}", FetchInfoOneHandler) http.Handle("/", r) @@ -126,7 +127,7 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) { } -func FetchInfoHandler(w http.ResponseWriter, r *http.Request) { +func FetchInfoOneHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) idString := vars["id"] if idString != "" { @@ -148,6 +149,11 @@ func FetchInfoHandler(w http.ResponseWriter, r *http.Request) { } } +func FetchInfoHandler(w http.ResponseWriter, r *http.Request) { + b, _ := json.Marshal(downloads) + w.Write(b) +} + func FetchHandler(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() diff --git a/web/index.html b/web/index.html index 2b88232..d8047ab 100644 --- a/web/index.html +++ b/web/index.html @@ -6,7 +6,7 @@

-
+
@@ -14,16 +14,21 @@ + + + {{ range $k, $v := .Downloads }} - - - - - - - - - {{ end }}
{{ $v.Id }}{{ range $_, $f := $v.Files }}{{ $f }}
{{ end }}
link{{ $v.State }}{{ $v.Percent }}{{ $v.Eta }}{{ $v.Finished }}
@@ -31,4 +36,19 @@ {{ end }} {{ define "js" }} + {{ end }} \ No newline at end of file