gitmyhub

http-server

★ 15 updated 4y ago ⑂ fork

a simple zero-configuration command-line http server

A zero-config command-line tool that instantly turns any folder on your computer into a local website you can open in your browser, perfect for quick previews and file sharing.

Node.jsJavaScriptsetup: easycomplexity 2/5

http-server is a tool that turns any folder on your computer into a working website you can open in your browser. Instead of dealing with complex web server setups, you just point it at a directory and it serves those files at a local web address like http://localhost:8080.

Under the hood, it looks for a folder called "public" (or uses your current directory) and makes everything inside it available on the web. If someone visits a folder, it shows a listing of files. If there's an "index.html" file in a folder, that gets served automatically. It also handles practical details like caching, optional password protection, and support for HTTPS if you provide security certificates.

This is useful for anyone who needs to quickly share or preview files over the web. A designer could use it to show a static HTML prototype to a client. A developer might use it to test how a built website behaves in a browser before deploying it for real. A teacher could use it to share course materials with students on the same network. You can even run it without installing anything using npx, which downloads and runs it on the fly.

What makes this tool appealing is its zero-configuration approach. You don't need to write config files or understand server administration to get a basic site running. It includes sensible defaults like cache headers and directory listings, but offers optional flags for things like CORS, gzip compression, and proxying requests to another server. There's also a useful trick for single-page apps: if you create a "404.html" file, it serves that instead of a generic error, which lets frameworks like React or Vue handle their own client-side routing.

Where it fits