Last active
February 26, 2018 01:44
-
-
Save killdash9/e073b182aa101aca52625f945ec5ddca to your computer and use it in GitHub Desktop.
A minimal HTTP server in bash that listens on port 1234
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
#!/bin/bash | |
#Serves the current directory. | |
test -p .f||mkfifo .f;while :;do cat .f|nc -l ${1:-1234}|(read m u p;echo $u;u=${u#/};{ echo -e 'HTTP/1.0 200 OK\nContent-type:text/html\n';test -d $u&&ls $u|sed "s,.*,<a href=\"$u/&\">&<br>,"||cat $u;}>.f);done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment