all repos — nimhttpd @ f2dc3d098056e4027d1dbc5841a816072de7b3ea

A useful static file web server.

Changed default address to 0.0.0.0; formatted startup info message.
h3rald h3rald@h3rald.com
Fri, 11 Sep 2020 17:42:55 +0200
commit

f2dc3d098056e4027d1dbc5841a816072de7b3ea

parent

a078fdf2349c4f97ceb7cecdb41eb13626d6f040

4 files changed, 12 insertions(+), 10 deletions(-)

jump to
M .gitignore.gitignore

@@ -1,4 +1,4 @@

nimcache/ -nimhttpd +nimhttpd* *.zip nakefile
M nimhttpd.nimblenimhttpd.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.nimsrc/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.nimsrc/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."