Quick-start a HTTP server
Serve an empty response once and exit
macOS
$ { echo "HTTP/1.0 200 OK" } | nc -l 8080
Serve an empty response
macOS
$ while :; do { echo "HTTP/1.0 200 OK" } | nc -l 8080; done
Serve a file once and exit
macOS
$ { echo -n "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c </path/to/file)\r\n\r\n"; cat /path/to/file; } | nc -l 8080
Serve a file
macOS
$ while :; do { echo -n "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c </path/to/file)\r\n\r\n"; cat /path/to/file; } | nc -l 8080; done
Serve the working directory and its files statically
$ npx serve # requires npm
Last updated
Was this helpful?