Changed default address to 0.0.0.0; formatted startup info message.
h3rald h3rald@h3rald.com
Fri, 11 Sep 2020 17:42:55 +0200
4 files changed,
12 insertions(+),
10 deletions(-)
M
nimhttpd.nimble
→
nimhttpd.nimble
@@ -1,9 +1,9 @@
import - ospaths + os template thisModuleFile: string = instantiationInfo(fullPaths = true).filename -when fileExists(thisModuleFile.parentDir / "src/nimhttpdpkg/config.nim"): +when system.fileExists(thisModuleFile.parentDir / "src/nimhttpdpkg/config.nim"): # In the git repository the Nimble sources are in a ``src`` directory. import src/nimhttpdpkg/config else:
M
src/nimhttpd.nim
→
src/nimhttpd.nim
@@ -20,12 +20,11 @@ version = pkgVersion
style = "style.css".slurp description = pkgDescription author = pkgAuthor - addressDefault = "127.0.0.1" - # TODO: `python3 -m http.server` instead uses `0.0.0.0`, which is the better default? + addressDefault = "0.0.0.0" portDefault = 1337 let usage = """ $1 v$2 - $3 - (c) 2014-2018 $4 + (c) 2014-2020 $4 Usage: nimhttpd [-p:port] [directory]@@ -145,11 +144,14 @@
setControlCHook(handleCtrlC) proc genMsg(settings: NimHttpSettings): string = - let port2 = $settings.port.int - let url = "http://$1:$2/" % [settings.address, port2] + let url = "http://$1:$2/" % [settings.address, $settings.port.int] let t = now() let pid = getCurrentProcessId() - result = "$1 v$2 started on port: $3 at: $4 serving: $5 time: $6 pid: $7" % [settings.name, settings.version, port2, url, settings.directory.quoteShell, $t, $pid] + result = """$1 v$2 +Address: $3 +Directory: $4 +Current Time: $5 +PID: $6""" % [settings.name, settings.version, url, settings.directory.quoteShell, $t, $pid] proc serve*(settings: NimHttpSettings) = var server = newAsyncHttpServer()
M
src/nimhttpdpkg/config.nim
→
src/nimhttpdpkg/config.nim
@@ -1,5 +1,5 @@
const pkgTitle* = "NimHTTPd" - pkgVersion* = "1.0.8" + pkgVersion* = "1.0.9" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "A tiny static file web server."