all repos — nimhttpd @ c6bb3d817b2e69b183c88ec68e47916a3b78bc0b

A useful static file web server.

Merge branch 'master' of github.com:h3rald/nimhttpd
h3rald h3rald@h3rald.com
Mon, 30 Sep 2019 14:21:03 +0200
commit

c6bb3d817b2e69b183c88ec68e47916a3b78bc0b

parent

816196289a37d36c6be7990b66cd4e33e4597b9b

2 files changed, 7 insertions(+), 3 deletions(-)

jump to
M src/nimhttpd.nimsrc/nimhttpd.nim

@@ -8,7 +8,8 @@ times,

parseopt, parsecfg, streams, - strutils + strutils, + uri from httpcore import HttpMethod, HttpHeaders

@@ -34,6 +35,7 @@ directory The directory to serve (default: current directory).

Options: -p, --port The port to listen to (default: 1337). + -a, --address The address to listen to (default: 127.0.0.1). """ % [name, version, description, author]

@@ -146,7 +148,7 @@ proc serve*(settings: NimHttpSettings) =

var server = newAsyncHttpServer() proc handleHttpRequest(req: Request): Future[void] {.async.} = printReqInfo(settings, req) - let path = settings.directory/req.url.path.replace("%20", " ") + let path = settings.directory/req.url.path.replace("%20", " ").decodeUrl() var res: NimHttpResponse if req.reqMethod != HttpGet: res = sendNotImplemented(settings, path)

@@ -180,6 +182,8 @@ quit(0)

of "version", "v": echo version quit(0) + of "address", "a": + address = val of "port", "p": try: port = Port(val.parseInt)
M src/nimhttpdpkg/config.nimsrc/nimhttpdpkg/config.nim

@@ -1,5 +1,5 @@

const pkgTitle* = "NimHTTPd" - pkgVersion* = "1.0.7" + pkgVersion* = "1.0.8" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "A tiny static file web server."