From d96957565a8b799e4efbd947eb710b0a6d7be1ea Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Wed, 4 Jul 2018 17:13:01 -0700 Subject: wip adding /crawl/ manual crawl update --- web/web.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/web.go b/web/web.go index f7fec31..fdcec7a 100644 --- a/web/web.go +++ b/web/web.go @@ -201,6 +201,18 @@ func exportHandler(w http.ResponseWriter, r *http.Request) { return } +func crawlHandler(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "crawling...\n\n") + if f, ok := w.(http.Flusher); ok { + f.Flush() + } else { + log.Println("Damn, no flush") + } + crawler.Crawl() + fmt.Fprintf(w, "done...\n\n") + return +} + func fullTextHandler(w http.ResponseWriter, r *http.Request) { fmt.Printf("request: %v\n\n", r) @@ -298,6 +310,7 @@ func Serve() { http.HandleFunc("/tag/", AuthWrap(categoryHandler)) http.Handle("/image/", http.StripPrefix("/image/", AuthWrap(imageProxyHandler))) http.Handle("/export/", http.StripPrefix("/export/", AuthWrap(exportHandler))) + http.HandleFunc("/crawl/", AuthWrap(crawlHandler)) http.HandleFunc("/login/", loginHandler) http.HandleFunc("/logout/", logoutHandler) -- cgit v1.2.3