Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

twm’s blog: A web server as a shell script in a single line

$
0
0

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

whateverhostname:8080

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

This is some serious case of genius!


Viewing all articles
Browse latest Browse all 1725

Trending Articles