all repos — nimhttpd @ 159f166858849633718ee6d0ec2ac953f88251dd

A useful static file web server.

Removed nakefile, using new NimScript format for nimble file.
h3rald h3rald@h3rald.com
Sat, 05 May 2018 21:48:51 +0200
commit

159f166858849633718ee6d0ec2ac953f88251dd

parent

301242ed8bf652f4fbf6487cbfdb7b259b77a5c7

4 files changed, 68 insertions(+), 102 deletions(-)

jump to
D nakefile.nim

@@ -1,58 +0,0 @@

-import - nake - -import - nimhttpd - -const - compile = "nim c -d:release" - linux_x86 = "--cpu:i386 --os:linux" - linux_x64 = "--cpu:amd64 --os:linux" - linux_arm = "--cpu:arm --os:linux" - windows_x64 = "--cpu:amd64 --os:windows" - macosx_x64 = "" - #parallel = "--parallelBuild:1 --verbosity:3" - hs = "nimhttpd" - hs_file = "nimhttpd.nim" - zip = "zip -X" - -proc filename_for(os: string, arch: string): string = - return "nimhttpd" & "_v" & version & "_" & os & "_" & arch & ".zip" - -task "windows-x64-build", "Build NimHTTPd for Windows (x64)": - direshell compile, windows_x64, hs_file - -task "linux-x86-build", "Build NimHTTPd for Linux (x86)": - direshell compile, linux_x86, hs_file - -task "linux-x64-build", "Build NimHTTPd for Linux (x64)": - direshell compile, linux_x64, hs_file - -task "linux-arm-build", "Build NimHTTPd for Linux (ARM)": - direshell compile, linux_arm, hs_file - -task "macosx-x64-build", "Build NimHTTPd for Mac OS X (x64)": - direshell compile, macosx_x64, hs_file - -task "release", "Release NimHTTPd": - echo "\n\n\n WINDOWS - x64:\n\n" - runTask "windows-x64-build" - direshell zip, filename_for("windows", "x64"), hs & ".exe" - direshell "rm", hs & ".exe" - echo "\n\n\n LINUX - x64:\n\n" - runTask "linux-x64-build" - direshell zip, filename_for("linux", "x64"), hs - direshell "rm", hs - echo "\n\n\n LINUX - x86:\n\n" - runTask "linux-x86-build" - direshell zip, filename_for("linux", "x86"), hs - direshell "rm", hs - echo "\n\n\n LINUX - ARM:\n\n" - runTask "linux-arm-build" - direshell zip, filename_for("linux", "arm"), hs - direshell "rm", hs - echo "\n\n\n MAC OS X - x64:\n\n" - runTask "macosx-x64-build" - direshell zip, filename_for("macosx", "x64"), hs - direshell "rm", hs - echo "\n\n\n ALL DONE!"
M nimhttpd.nimnimhttpd.nim

@@ -9,45 +9,15 @@ parseopt,

parsecfg, streams, strutils + from httpcore import HttpMethod, HttpHeaders + const + name = "NimHTTPd" + version = "1.0.5" style = "style.css".slurp - cfgfile = "nimhttpd.nimble".slurp - -var - name* = "NimHTTPd" - version*: string - description*: string - f = newStringStream(cfgfile) - -if f != nil: - var p: CfgParser - open(p, f, "../litestore.nimble") - while true: - var e = next(p) - case e.kind - of cfgEof: - break - of cfgKeyValuePair: - case e.key: - of "version": - version = e.value - of "description": - description = e.value - else: - discard - of cfgError: - stderr.writeLine("Configuration error.") - quit(1) - else: - discard - close(p) -else: - stderr.writeLine("Cannot process configuration file.") - quit(2) - - + description = "A tiny static file web server" let usage = name & " v" & version & " - " & description & """
M nimhttpd.nim.cfgnimhttpd.nim.cfg

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

-define:release - # https://gist.github.com/Drakulix/9881160 amd64.windows.gcc.path = "/usr/local/mingw/bin" amd64.windows.gcc.exe = "x86_64-w64-mingw32-gcc"
M nimhttpd.nimblenimhttpd.nimble

@@ -1,11 +1,67 @@

-[Package] -name = "nimhttpd" -version = "1.0.4" +# Package + +version = "1.0.5" author = "Fabio Cevasco" description = "A tiny static file web server." license = "MIT" -bin = "nimhttpd" -skipFiles = @["nakefile.nim"] +bin = @["nimhttpd"] +srcDir = "src" + +# Dependencies + +requires "nim >= 0.18.0" + +const compile = "nim c -d:release" +const linux_x86 = "--cpu:i386 --os:linux" +const linux_x64 = "--cpu:amd64 --os:linux" +const linux_arm = "--cpu:arm --os:linux" +const windows_x64 = "--cpu:amd64 --os:windows" +const macosx_x64 = "" +const program = "nimhttpd" +const program_file = "nimhttpd.nim" +const zip = "zip -X" + +proc shell(command, args: string, dest = "") = + exec command & " " & args & " " & dest + +proc filename_for(os: string, arch: string): string = + return "nimhttpd" & "_v" & version & "_" & os & "_" & arch & ".zip" -[Deps] -requires: "nim >= 0.18.0" +task windows_x64_build, "Build NimHTTPd for Windows (x64)": + shell compile, windows_x64, program_file + +task linux_x86_build, "Build NimHTTPd for Linux (x86)": + shell compile, linux_x86, program_file + +task linux_x64_build, "Build NimHTTPd for Linux (x64)": + shell compile, linux_x64, program_file + +task linux_arm_build, "Build NimHTTPd for Linux (ARM)": + shell compile, linux_arm, program_file + +task macosx_x64_build, "Build NimHTTPd for Mac OS X (x64)": + shell compile, macosx_x64, program_file + +task release, "Release NimHTTPd": + echo "\n\n\n WINDOWS - x64:\n\n" + windows_x64_buildTask() + shell zip, filename_for("windows", "x64"), program & ".exe" + shell "rm", program & ".exe" + echo "\n\n\n LINUX - x64:\n\n" + linux_x64_buildTask() + shell zip, filename_for("linux", "x64"), program + shell "rm", program + echo "\n\n\n LINUX - x86:\n\n" + linux_x86_buildTask() + shell zip, filename_for("linux", "x86"), program + shell "rm", program + echo "\n\n\n LINUX - ARM:\n\n" + linux_arm_buildTask() + shell zip, filename_for("linux", "arm"), program + shell "rm", program + echo "\n\n\n MAC OS X - x64:\n\n" + macosx_x64_buildTask() + shell zip, filename_for("macosx", "x64"), program + shell "rm", program + echo "\n\n\n ALL DONE!" +