📜 ⬆️ ⬇️

HTTP server on bash

Quite a full-featured HTTP server, written in bash, in one line.

:;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$rabc;z=$r;while [ ${#z} -gt 2 ];do $rz;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z $f ];then($e $o;ls|(while $rn;do if [ -f "$n" ]; then $e "`ls -gh $n`";fi;done););elif [ -f $f ];then $e "$o$c-Type: `file -ib $f`\n$c-Length: `stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done

The author of this perversion of a curious project is Alexey Sveshnikov .

')

Source: https://habr.com/ru/post/37245/


All Articles