commit 8c4ccfe8dad722d79abed1f66d0215e6a450d20e
parent 7d63161f752022cab3df8b53337b79f9c349ba93
Author: Leah Thein <leah@toaster.fritz.box>
Date: Sat, 5 Dec 2020 09:47:59 +0100
parent 7d63161f752022cab3df8b53337b79f9c349ba93
Author: Leah Thein <leah@toaster.fritz.box>
Date: Sat, 5 Dec 2020 09:47:59 +0100
set port via env-var
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/asyncWebServer.nim b/src/asyncWebServer.nim @@ -10,11 +10,11 @@ export tables, json type ServerRef* = ref object - port*: uint16 + port*: int address*: string server*: AsyncHttpServer -proc newServer* (address: string = "0.0.0.0", port: uint16 = 5000): ServerRef = +proc newServer* (address: string = "0.0.0.0", port: int = 5000): ServerRef = return ServerRef( address: address, port: port,
diff --git a/src/oeffi_nojs.nim b/src/oeffi_nojs.nim @@ -32,6 +32,11 @@ proc main = # for gcsafe removePidFile() quit() + var port = 5000 + + if getEnv("PORT") != "": + port = parseInt(getEnv("PORT")) + if getEnv("CACHE_PATH") == "": echo "CACHE_PATH not set! Bye...." quit(1) @@ -45,7 +50,7 @@ proc main = # for gcsafe echo "Can't write pid file!" quit(1) - var server = newServer() # launch on http://localhost:5000 + var server = newServer("0.0.0.0", port) # launch on http://localhost:5000 server.pages: equals("/"):