television

a simple LAN/WLAN desktop public broadcasting service
Log | Files | Refs | README

commit 71a498f1418ea2ceb1b7946f3da130fc6ff2ca16
parent 2a08a59a089f0d51b1b4d39554ac83e519d3cc23
Author: ugrnm <ultrageranium@bleu255.com>
Date:   Mon, 16 Sep 2024 16:34:05 +0200

port number flag + fmt in place of log

Diffstat:
Mtelevision.go | 20+++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/television.go b/television.go @@ -1,14 +1,21 @@ package main import ( + "flag" "os" - "log" + "fmt" "time" "net/http" "github.com/kbinani/screenshot" "github.com/pixiv/go-libjpeg/jpeg" ) +var( + portNum int +// strFlag string +// boolFlag bool +) + func snap() { for { @@ -30,7 +37,7 @@ func snap() { os.Rename(fileName, "www/tv.jpg") - log.Println("screenshot taken") + fmt.Printf("screenshot taken\n") time.Sleep(1000 * time.Millisecond) @@ -39,13 +46,16 @@ func snap() { func main() { + flag.IntVar(&portNum, "port", 8888, "http port number") + flag.Parse() + go snap() - log.Println("we're live!") - log.Println("ctrl-c for emergency shutdown") + fmt.Printf("we're live on port %d!\n", portNum) + fmt.Printf("ctrl-c for emergency shutdown\n") http.Handle("/", http.FileServer(http.Dir("www"))) - http.ListenAndServe(":8888", nil) + http.ListenAndServe(":" + fmt.Sprintf("%d", portNum), nil) }