Created
January 23, 2015 19:57
-
-
Save talwai/d94c71ca09729ac655b4 to your computer and use it in GitHub Desktop.
One-shot HTTP webserver to serve file contents using netcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l 8080 |
I usually need to invoke netcat using nc -l -p 8080
, but otherwise this is perfect and has been useful to me many times.
Thanks!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: http://en.wikipedia.org/wiki/Netcat