Hi everyone,
I wanted to share a small tool I've been working on called NServe.
Repo: https://github.com/heckarmon/nserve
We all use python -m http.server to quickly serve files, but I often found myself needing two things it doesn't provide out of the box: concurrency and file uploads.
NServe is my attempt at a "batteries-included" alternative written in pure Nim. It compiles to a single executable with zero runtime dependencies and uses asynchttpserver + asyncnet to handle connections non-blocking.
It was a fun exercise in using Nim's async stack for a practical CLI tool. I'd love to hear any feedback on the code or suggestions for improvements!
Contributions are welcome!
Cheers!
See how the memory consumption and blocking behaves with gigabyte sized files which are not too uncommon these days. In the past the stdlib struggled with that, to say the least... Then see if you can fix issues by patching the stdlib. :-)
If you don't need this, at least add some filesize limit and report an error properly.
I haven’t stress-tested with multi-GB files yet, so that’s definitely on my radar. Right now the focus was more on correctness and ergonomics than extreme payloads, but you’re absolutely right that large uploads are common enough to deserve first-class handling.
I’m planning to add a configurable file size limit and proper error reporting in the short term. Longer term, I’d like to experiment with more explicit streaming behavior to avoid unnecessary buffering and see how far the current async stack can be pushed.
If I do run into stdlib limitations along the way, I’d be very happy to dig in and try to fix or improve them upstream — that would be a win for everyone.
Really appreciate the nudge and the perspective!
I can also recommend implementing byte headers, so that you can request parts of the file, also with an offset. This is needed for fast forwarding audio und Video streams.
I would also generate clickable links on startup with all the listening URL. Maybe even generate a QR code for mobile phones.
ergonomics
little nit pick, y'r "up arrow" image for parent directory does not work as a link/button.
Nice work!
Release v1.0.2: https://github.com/heckarmon/nserve/releases/tag/v1.0.2
@Araq, I have implemented the suggested filesize limit with the corresponding cues on UI.
@ingo, The little details are what really make a nice experience, I have made the necessary changes to make the entire card clickable. Thank you for the suggestion.
Also I feel the the single file philosophy for simplicity is getting a bit out of hand with the sheer amount of code.
It'd be great to get some feedback on whether I break the entire codebase into more readable chunks for brevity or maintain a single file for simplicity.
Release v.1.0.3: https://github.com/heckarmon/nserve/releases/tag/v1.0.3
✅QR encoding of URLs for mobile phones
✅ Now officially a Nim package you can install using nimble install nserve
Presently sticking with single file philosophy
the single file philosophy
A bit depending on the content and the amount of code folding what one can get, ~500 lines is my max. That' still scrollable for me although I mostly split by "subject".
v1.0.4: https://github.com/heckarmon/nserve/releases/tag/v1.0.4
Directory zipping + QR!!
Just recommendation: Try to make its ui like google drive drag and drop, upload thumbnail and preview (image, pdf video) also you can restrict filetypes maybe for upload or download and sanitize the path for security ? Maybe add some progress bar and other ui ux improvement like grid layout sorting files by size date type and other.
Also add some websocket kind of things to do some realtime updates.
This are some points in my mind, but adding features will not end continuously as human demands new things.
Also I feel the the single file philosophy for simplicity is getting a bit out of hand with the sheer amount of code.
It'd be great to get some feedback on whether I break the entire codebase into more readable chunks for brevity or maintain a single file for simplicity.
for what it's worth, i always liked refactoring in the forth philosophy spirit.
(and this is a classic in my opinion: https://thinking-forth.sourceforge.net/ )