How-to

Serve a folder over HTTP in one line

Updated Jul 4, 2026 1 min

When I need to preview a static site or share a folder on my network for a minute, I do not want to set up a project. These one-liners serve the current directory over HTTP with tools that are already installed.

Python (already on macOS and most Linux)

python3 -m http.server 8000

Then open http://localhost:8000. Add an address to expose it on your network:

python3 -m http.server 8000 --bind 0.0.0.0

Node, without installing anything

npx serve .

npx fetches serve on the fly and runs it. It prints both a local and a network URL, and handles single-page-app routing better than the Python one.

PHP, if it happens to be around

php -S localhost:8000

Which one I pick

For a plain folder of files, the Python server is the fastest thing that is always there. For anything that behaves like an app (client-side routing, clean URLs), npx serve saves me the headaches.