Skip to content

Instantly share code, notes, and snippets.

@dwallraff
Last active February 15, 2017 17:51
Show Gist options
  • Select an option

  • Save dwallraff/4d959ab49dc236ded26225eaab627b0c to your computer and use it in GitHub Desktop.

Select an option

Save dwallraff/4d959ab49dc236ded26225eaab627b0c to your computer and use it in GitHub Desktop.
Various CLI Web Server examples (netcat, socat, perl, python)
# Netcat
while true ; do nc -k -l 80 < index.html ; done
# Perl
perl -MIO::Socket::INET -ne \
'BEGIN{$l=IO::Socket::INET->new(LocalPort=>80,Proto=>"tcp",Listen=>5,ReuseAddr=>1);\
$l=$l->accept}print $l $_' < index.html
# Socat
socat -u - tcp-listen:80,reuseaddr < index.html
# Python (serves on 8000)
python -m SimpleHTTPServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment