~h3rald/nimhttpd

5fab608a5571d44d4f203d86c72145075268c280 — Michael Adams 1 year, 8 months ago 9c0a59a
tweaks
2 files changed, 13 insertions(+), 12 deletions(-)

M src/nimhttpd.nim
M src/nimhttpdpkg/config.nim
M src/nimhttpd.nim => src/nimhttpd.nim +12 -11
@@ 1,11 1,12 @@
import 
  asyncdispatch,
  asynchttpserver, 
  asynchttpserver,
  macros,
  mimetypes, 
  nativesockets,
  os,
  parseopt,
  strutils, 
  strutils,
  times, 
  uri
  


@@ 109,20 110,20 @@ proc sendNotImplemented(settings: NimHttpSettings, path: string): NimHttpRespons
  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.nim => src/nimhttpdpkg/config.nim +1 -1
@@ 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!"