From 77131adb72e21792e3a54ec4d34fe9ea77198734 Mon Sep 17 00:00:00 2001 From: Tilo-K Date: Sat, 8 Jul 2023 10:29:47 +0200 Subject: [PATCH] Added dynamic port --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3da2fc9..297bf13 100644 --- a/main.go +++ b/main.go @@ -252,9 +252,14 @@ func main() { fs := http.FileServer(http.Dir(filepath.Join(storageDir, "data"))) http.Handle("/", cors(fs)) + port := os.Getenv("Port") - log.Print("Listening on :60002...") - err := http.ListenAndServe(":60002", nil) + if port == ""{ + port = "60002" + } + + log.Print("Listening on :" + port + "...") + err := http.ListenAndServe(":" + port, nil) if err != nil { log.Fatal(err) }