A web server as a shell script – in a single line

I just found this via Heise online:

Web server in one line of bash

I tried it and it works!

while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html; } | nc -l 8080; done

You can replace index.html with any file you happen to want to transfer (also works for binary files).

After executing this, just point your browser to


and it will start downloading the file or in the case of index.html, will display it.

This is some serious case of genius!