Skip to content

Instantly share code, notes, and snippets.

@talwai
Created January 23, 2015 19:57
Show Gist options
  • Save talwai/d94c71ca09729ac655b4 to your computer and use it in GitHub Desktop.
Save talwai/d94c71ca09729ac655b4 to your computer and use it in GitHub Desktop.
One-shot HTTP webserver to serve file contents using netcat
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <some.file)\r\n\r\n"; cat some.file; } | nc -l 8080
@talwai
Copy link
Author

talwai commented Jan 23, 2015

@zfortier
Copy link

zfortier commented Jan 6, 2021

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