Last active
May 31, 2017 06:37
-
-
Save juji/37d413f5cd19b4e433e8592880f07531 to your computer and use it in GitHub Desktop.
bash 5 line server
This file contains 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 | |
# usage: | |
# ./server.sh [port] [response] | |
# | |
RESPONSE="HTTP/1.1 200 OK\r\nConnection: keep-alive\r\n\r\n${2:-"OK"}\r\n" | |
while { echo -en "$RESPONSE"; } | nc -q 0 -l -p "${1:-8080}"; do | |
echo "================================================" | |
echo "you can do stuff on request" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment