static-server: an HTTP server in Go for static content

submited by
Style Pass
2023-09-16 14:00:08

I put together a simple static file server in Go - useful for local testing of web applications. Check it out at

And it will start serving the current directory! Run it with -help for usage information. No configuration files needed - the default is useful and you can adjust it to your needs using command-line flags.

When developing web applications locally, for basic test cases we can open an HTML file directly in the browser (using file:/// scheme). However, this is sometimes insufficient, and in several scenarios it's necessary to properly serve the HTML (along with its JS and CSS). Some cases where I encountered this are web applications that use at least one of:

In the past, when I was more active in the Python ecosystem, I used python -m SimpleHTTPServer <port> quite a bit. While it's nice, it has some issues too: it's not very configurable, and it requires Python to be installed.

Another option I've used is http-server from the Node.js ecosystem; in fact, it has served as the inspiration for static-server . You can run it with npx without installing, and it's also configurable through command-line flags, without requiring configuration files.

Leave a Comment