diff --git a/wrp.go b/wrp.go index 625e7e8..f477bac 100644 --- a/wrp.go +++ b/wrp.go @@ -72,22 +72,22 @@ func pageServer(out http.ResponseWriter, r *http.Request) { } log.Printf("%s Page Reqest for url=\"%s\" [%s]\n", r.RemoteAddr, u, r.URL.Path) out.Header().Set("Content-Type", "text/html") - fmt.Fprintf(out, "\n
") + fmt.Fprintf(out, "
\n") if len(u) > 4 { if strings.HasPrefix(u, "http") { - capture(u, w, h, s, p, out) + capture(u, w, h, s, p, i, out) } else { - capture(fmt.Sprintf("http://www.google.com/search?q=%s", url.QueryEscape(u)), w, h, s, p, out) + capture(fmt.Sprintf("http://www.google.com/search?q=%s", url.QueryEscape(u)), w, h, s, p, i, out) } } else { fmt.Fprintf(out, "No URL or search query specified") @@ -96,7 +96,7 @@ func pageServer(out http.ResponseWriter, r *http.Request) { } func imgServer(out http.ResponseWriter, req *http.Request) { - log.Printf("%s Img Request for %s\n", req.RemoteAddr, req.URL.Path) + log.Printf("%s IMG Request for %s\n", req.RemoteAddr, req.URL.Path) gifbuf := gifmap[req.URL.Path] defer delete(gifmap, req.URL.Path) out.Header().Set("Content-Type", "image/gif") @@ -105,6 +105,11 @@ func imgServer(out http.ResponseWriter, req *http.Request) { out.(http.Flusher).Flush() } +func mapServer(out http.ResponseWriter, req *http.Request) { + log.Printf("%s MAP Request for %s [%v]\n", req.RemoteAddr, req.URL.Path, req.URL.Query()) +} + + func haltServer(out http.ResponseWriter, req *http.Request) { log.Printf("%s Shutdown request received [%s]\n", req.RemoteAddr, req.URL.Path) out.Header().Set("Content-Type", "text/plain") @@ -114,7 +119,7 @@ func haltServer(out http.ResponseWriter, req *http.Request) { os.Exit(0) } -func capture(gourl string, w int64, h int64, s float64, p int64, out http.ResponseWriter) { +func capture(gourl string, w int64, h int64, s float64, p int64, ismap bool, out http.ResponseWriter) { var nodes []*cdp.Node ctxx := chromedp.FromContext(ctx) var pngbuf []byte @@ -163,7 +168,11 @@ func capture(gourl string, w int64, h int64, s float64, p int64, out http.Respon // Process Nodes base, _ := url.Parse(loc) - fmt.Fprintf(out, "\n\n") + } out.(http.Flusher).Flush() log.Printf("Done with caputure for %s\n", gourl) } @@ -196,6 +211,7 @@ func main() { rand.Seed(time.Now().UnixNano()) http.HandleFunc("/", pageServer) http.HandleFunc("/img/", imgServer) + http.HandleFunc("/map/", mapServer) http.HandleFunc("/favicon.ico", http.NotFound) http.HandleFunc("/halt", haltServer) log.Printf("Starting WRP http server on %s\n", addr)