A simple HTTP server for serving a directory.
usage: serve [-h] directory
a simple HTTP server for serving a directory
positional arguments:
directory the directory to serve
optional arguments:
-h, --help show this help message and exit
You can use the tool simply by running:
serve dist # or whatever path to the directory you want to serveThis will serve the dist/ directory at a random free port on your system.
You can view the help by using --help or -h:
serve -h
serve --helpFor a given request /path/to/url, the order in which files are served are:
- If
directory/path/to/urlexists, return it. - If
directory/path/to/url.htmlexists, return it. - If
directory/path/to/url/index.htmlexists, return it. - If
directory/404.htmlexists, return it with status code 404. - Return an empty response with status code 404.
You'll need Python (tested on Python 3.9.6 and 3.15.1). It should be built-in on most Linux and macOS systems.
git clone https://github.com/noClaps/serve.git && cd serve
install ./serve ~/.local/bin/ # or somewhere else on your PATH