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