add flags

This commit is contained in:
Antoni Sawicki 2019-05-29 01:52:28 -07:00
parent e869291f8e
commit 0680b4a72e

8
wrp.go
View File

@ -2,6 +2,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
@ -82,9 +83,12 @@ func capture(url string, out http.ResponseWriter) {
func main() {
ctx, cancel = chromedp.NewContext(context.Background())
defer cancel()
var addr string
flag.StringVar(&addr, "l", ":8080", "Listen address:port, default :8080")
flag.Parse()
http.HandleFunc("/", pageServer)
http.HandleFunc("/wrp.png", imgServer)
log.Printf("Starting http server on :8080\n")
http.ListenAndServe(":8080", nil)
log.Printf("Starting http server on %s\n", addr)
http.ListenAndServe(addr, nil)
}