Created
August 20, 2017 10:24
-
-
Save imesh/ed6eda3a01aadeebdd17048cb58acbed to your computer and use it in GitHub Desktop.
Bash HTTP 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 | |
ip=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'` | |
response="HTTP/1.1 200 OK\r\nConnection: keep-alive\r\n\r\n${2:-"OK ${ip}"}\r\n" | |
while { echo -en "${response}"; } | nc -l "${1:-8080}"; do | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment