Skip to content

Instantly share code, notes, and snippets.

@talwai
Created January 23, 2015 19:57
Show Gist options
  • Select an option

  • Save talwai/d94c71ca09729ac655b4 to your computer and use it in GitHub Desktop.

Select an option

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

talwai commented Jan 23, 2015

Copy link
Copy Markdown
Author

@zfortier

zfortier commented Jan 6, 2021

Copy link
Copy Markdown

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