Skip to content

Instantly share code, notes, and snippets.

@nobu666
Last active January 21, 2019 14:16
Show Gist options
  • Save nobu666/2146276 to your computer and use it in GitHub Desktop.
Save nobu666/2146276 to your computer and use it in GitHub Desktop.
awk http server
awk 'BEGIN{s="/inet/tcp/80/0/0";"pwd" |& getline;r=$0;while((s |& getline) > 0){gsub(/[\r\n]/,"");if($0 ~ /^\s*$/){c="cat " r path;printf "HTTP/1.0 200 OK\r\n\r\n" |& s;while((c |& getline) > 0){print |& s}close(c);close(s)}else if($0 ~ /HTTP/){print;path=$2}}}'
@disq
Copy link

disq commented Aug 12, 2016

Replace >; with >.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment