Serve a directory with HTTP

1 min read

Source

Python

➜ python -m http.server 8000

# Force bind to IPv4
➜ python -m http.server 8000 -b 0.0.0.0

Rust

➜ cargo install https
➜ http
Hosting "." on port 8000...
Ctrl-C to stop.

Go

➜ go get github.com/sno6/gommand
➜ $GOPATH/bin/gommand 'http.ListenAndServe(":8000", http.FileServer(http.Dir(".")))'
# [Install Caddy](https://caddyserver.com/docs/install)
➜ caddy -port 8000

Unix tools

while true ; do nc -l 8000 < test.html ; done

Javascript

npm install -g http-server
➜ http-server -p 8000

# ornpm install -g node-static
➜ static -p 8000

#ornpm install -g serve
➜ serve .