Skip to content

Instantly share code, notes, and snippets.

@rm--
Last active February 1, 2018 10:01
Show Gist options
  • Save rm--/0095560f2554b89e6abb58974d5edfcd to your computer and use it in GitHub Desktop.
Save rm--/0095560f2554b89e6abb58974d5edfcd to your computer and use it in GitHub Desktop.
One command line web server using nc (netcat)

serve file as response

(macOS) while true; do printf 'HTTP/1.1 200 OK\r\n\r\n'; cat <file>; | nc -l 10100; done

(linux) while true; do printf 'HTTP/1.1 200 OK\r\n\r\n' && cat <file> | nc -l -p 10100; done

// use port > 1023 for non-root :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment