Configurable listen port
This commit is contained in:
12
Makefile
12
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
|
||||
|
5
lts.go
5
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user