Simple http file server

I am trying to have a simple http server who just serve the file in a given directory.
It is like the python -m htt.server, or the zig std, that serve local files.
There is in the standard library a http.Server, but there is no instruction about how to use it.
I know also that there is zap, who can serve my files, but I prefer to avoid dependencies.

The goal is just to provide a simple way to test my Zig code compiled to WASM through a webpage, during a build step (like zig build run).

I don’t know if it is simple or complicated, if I can reuse std code or not.
So any help is welcome !

I don’t agree with that, I think using a dependency is the way to solve this.

Avoiding dependencies seems strange to me, similar to sticking with zig test ... or zig build-exe ... for way too long, instead of writing a build.zig, but maybe that is because I don’t understand the appeal in some specific workflow, why do you want to avoid dependencies?

This is something that works for autodocs:

This dependency from player/build.zig.zon at main - andrewrk/player - Codeberg.org seems to provide more general functionality, that isn’t just for serving autodocs:
GitHub - andrewrk/StaticHttpFileServer: Zig module for serving a directory of files from memory via HTTP

I haven’t used it yet, but was planning to try to use it for a local development build step.

1 Like

Also this discussion is related:

I wonder if that solution could be implemented to be non-autodocs specific and instead work for wasm in general (maybe via customization).