zserve is a lightweight, high-performance static file server written in Zig. It's designed to be simple, fast, and easy to use for serving static websites, single-page applications, or any directory of files over HTTP.
- Fast & Efficient: Built with Zig for optimal performance and low resource usage.
- Simple to Use: Serve any directory with a single command.
- Configurable: Easily change the host and port.
- Cross-Platform: Runs on any platform supported by the Zig compiler.
You need to have the Zig compiler installed on your system. You can find installation instructions on the official Zig website.
-
Clone the repository:
git clone https://github.com/your-username/zserve.git cd zserve -
Build the project:
zig build
This will create an executable in the
zig-out/bindirectory.
You can run the server directly using zig build run or by executing the compiled binary. The server requires you to specify the folder you want to serve.
zig build run -- -f ./path/to/your/folderOr run the compiled binary:
./zig-out/bin/zserve -f ./path/to/your/folderThe server will start, and you can access your files in a web browser, by default at http://127.0.0.1:8080.
You can customize the server's behavior using the following command-line flags:
-f <path>: (Required) The path to the directory you want to serve files from.-h <host>: (Optional) The host address to bind the server to. Defaults to127.0.0.1.-p <port>: (Optional) The port for the server to listen on. Defaults to8080.
To serve files from a directory named my-website on port 3000:
zig build run -- -f ./my-website -p 3000Now you can access your site at http://127.0.0.1:3000.
Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub.
This project is licensed under the MIT License.