all repos — nimhttpd @ ee386274a8c0491285ac4931fb36175267c42580

A useful static file web server.

tweaks
Michael Adams unquietwiki@gmail.com
Sun, 15 Jan 2023 17:56:03 -0800
commit

ee386274a8c0491285ac4931fb36175267c42580

parent

6606091dbc99480297cc34dcfccdfc682f129463

2 files changed, 13 insertions(+), 12 deletions(-)

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

@@ -1,11 +1,12 @@

import asyncdispatch, - asynchttpserver, + asynchttpserver, + macros, mimetypes, nativesockets, os, parseopt, - strutils, + strutils, times, uri

@@ -109,20 +110,20 @@ var content = "<p>This server does not support the functionality required to fulfill the request.</p>"

return (code: Http501, content: hPage(settings, content, $int(Http501), "Not Implemented"), headers: {"Content-Type": "text/html"}.newHttpHeaders()) proc sendStaticFile(settings: NimHttpSettings, path: string): NimHttpResponse = - let mimes = settings.mimes - var ext = path.splitFile.ext - if ext == "": - ext = ".txt" - ext = ext[1 .. ^1] + var + mimes = settings.mimes + ext = path.splitFile.ext + if ext == "": ext = ".txt" else: ext = ext[1 .. ^1] let mimetype = mimes.getMimetype(ext.toLowerAscii) var file = path.readFile return (code: Http200, content: file, headers: {"Content-Type": mimetype}.newHttpHeaders) proc sendDirContents(settings: NimHttpSettings, dir: string): NimHttpResponse = - let cwd = settings.directory.absolutePath - var res: NimHttpResponse - var files = newSeq[string](0) - var path = dir.absolutePath + var + res: NimHttpResponse + cwd = settings.directory.absolutePath + files = newSeq[string](0) + path = dir.absolutePath if not path.startsWith(cwd): path = cwd if path != cwd and path != cwd&"/" and path != cwd&"\\":
M src/nimhttpdpkg/config.nimsrc/nimhttpdpkg/config.nim

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

const pkgTitle* = "NimHTTPd" - pkgVersion* = "1.4.0" + pkgVersion* = "1.4.1" pkgAuthor* = "Fabio Cevasco & Michael Adams" pkgDescription* = "A tiny static file web server. IPv4 & IPv6 supported!"