Skip to content

Instantly share code, notes, and snippets.

@stretchkennedy
Created July 29, 2016 11:49
Show Gist options
  • Save stretchkennedy/7c594eb167971c9f7e9886b5568801b1 to your computer and use it in GitHub Desktop.
Save stretchkennedy/7c594eb167971c9f7e9886b5568801b1 to your computer and use it in GitHub Desktop.
http server
# bash one-liner to run a simple (and possibly non-compliant) http server
ncat -l 2000 -k -c '/bin/echo -e "HTTP/1.0 200 OK\r\n\r\n<html><body><h1>Test page</h1></body></html>"'
# more comprehensive version that sets Content-Type and Content-Length
CONTENT='<html><body><h1>Test page</h1></body></html>'; ncat -l 2000 -k -c '/bin/echo -e "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: '${#CONTENT}'\r\n\r\n'$CONTENT'"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment