commit bd4473e8fad6276eaad45127a23453c7e971526b
parent 71a498f1418ea2ceb1b7946f3da130fc6ff2ca16
Author: ugrnm <ultrageranium@bleu255.com>
Date: Mon, 16 Sep 2024 16:41:20 +0200
www directory flag
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/television.go b/television.go
@@ -11,9 +11,8 @@ import (
)
var(
- portNum int
-// strFlag string
-// boolFlag bool
+ portNum int
+ wwwDir string
)
func snap() {
@@ -25,7 +24,7 @@ func snap() {
panic(err)
}
- fileName := "www/tv.jpg.tmp"
+ fileName := wwwDir + "/tv.jpg.tmp"
file, _ := os.Create(fileName)
defer file.Close()
@@ -35,7 +34,7 @@ func snap() {
ProgressiveMode: false,
DCTMethod: jpeg.DCTIFast})
- os.Rename(fileName, "www/tv.jpg")
+ os.Rename(fileName, wwwDir + "/tv.jpg")
fmt.Printf("screenshot taken\n")
@@ -47,6 +46,7 @@ func snap() {
func main() {
flag.IntVar(&portNum, "port", 8888, "http port number")
+ flag.StringVar(&wwwDir, "www", "./www", "www directory")
flag.Parse()
go snap()
@@ -54,7 +54,7 @@ func main() {
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.Handle("/", http.FileServer(http.Dir(wwwDir)))
http.ListenAndServe(":" + fmt.Sprintf("%d", portNum), nil)
}