all repos — nimhttpd @ 9f65d9903d10f0526d33c80fbf3bbaa68ce8228c

A useful static file web server.

Fixed warnings.
h3rald h3rald@h3rald.com
Thu, 08 Dec 2022 18:28:28 +0000
commit

9f65d9903d10f0526d33c80fbf3bbaa68ce8228c

parent

de7bbba7a6038154c144acf2e920d85be16c9993

1 files changed, 5 insertions(+), 6 deletions(-)

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

@@ -7,8 +7,7 @@ os,

parseopt, strutils, times, - uri, - strscans + uri from httpcore import HttpMethod, HttpHeaders, parseHeader

@@ -60,7 +59,7 @@ address*: string

name*: string version*: string headers*: HttpHeaders -proc h_page(settings:NimHttpSettings, content, title, subtitle: string): string = +proc hPage(settings:NimHttpSettings, content, title, subtitle: string): string = var footer = """<div id="footer">$1 v$2</div>""" % [settings.name, settings.version] result = """ <!DOCTYPE html>

@@ -103,11 +102,11 @@ return relparent

proc sendNotFound(settings: NimHttpSettings, path: string): NimHttpResponse = var content = "<p>The page you requested cannot be found.<p>" - return (code: Http404, content: h_page(settings, content, $int(Http404), "Not Found"), headers: {"Content-Type": "text/html"}.newHttpHeaders()) + return (code: Http404, content: hPage(settings, content, $int(Http404), "Not Found"), headers: {"Content-Type": "text/html"}.newHttpHeaders()) proc sendNotImplemented(settings: NimHttpSettings, path: string): NimHttpResponse = var content = "<p>This server does not support the functionality required to fulfill the request.</p>" - return (code: Http501, content: h_page(settings, content, $int(Http501), "Not Implemented"), headers: {"Content-Type": "text/html"}.newHttpHeaders()) + 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

@@ -144,7 +143,7 @@ <ul>

$1 </ul> """ % [files.join("\n")] - res = (code: Http200, content: h_page(settings, ul, title, subtitle), headers: {"Content-Type": "text/html"}.newHttpHeaders()) + res = (code: Http200, content: hPage(settings, ul, title, subtitle), headers: {"Content-Type": "text/html"}.newHttpHeaders()) return res proc printReqInfo(settings: NimHttpSettings, req: Request) =