Last active
May 16, 2018 04:13
-
-
Save dylan4224/b956544aecf542bd98cea68e500e3687 to your computer and use it in GitHub Desktop.
Tiny HTTP Server powered by nc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # A Tiny HTTP Server powered by nc | |
| port=${1:-8080} | |
| echo "Tiny HTTP Server, listening on localhost:${port}" | |
| while true | |
| do | |
| { | |
| # Status line | |
| echo -e 'HTTP/1.0 200 OK\r'; | |
| # Headers | |
| echo -e 'Content-Type:text/plain\r'; | |
| echo -e '\r\n'; | |
| # Body | |
| echo -e 'Hello, World!\n'; | |
| } | nc -l ${port} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment