diff --git a/Makefile b/Makefile index 227979d..0c2ba90 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,15 @@ +BUILD_MODE ?= DEBUG + +ifeq ($(BUILD_MODE),DEBUG) + LISTEN_PORT = ":9090" +else ifeq ($(BUILD_MODE),RELEASE) + LISTEN_PORT = ":80" +else + $(error Unknown build mode) +endif + all: - go build + go build -ldflags="-X main.LISTEN_PORT=\"$(LISTEN_PORT)\"" watcher: cc -o watcher watcher.c diff --git a/lts.go b/lts.go index b993f3f..29f041f 100644 --- a/lts.go +++ b/lts.go @@ -17,6 +17,8 @@ import ( "github.com/fsnotify/fsnotify" ) +var LISTEN_PORT string + //go:embed tmpls/* var tmpls embed.FS @@ -114,6 +116,7 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Uploaded file: %s\n", handler.Filename) fmt.Fprintf(w, "File size: %s\n", byteCountSI(handler.Size)) + fmt.Fprintf(w, "Link: ") dst, err := createFile(storePath, handler.Filename) if err != nil { @@ -242,7 +245,7 @@ func main() { http.Handle("/etc/", http.FileServerFS(etc)) http.Handle("/store/", http.StripPrefix("/store/", http.FileServer(http.Dir(storePath)))) - http.ListenAndServe(":9090", nil) + http.ListenAndServe(LISTEN_PORT, nil) doneWatching<-true }