Shinatra – A simple bash web server
github.com
github.com
This is a much lighter and nicer version. This is going into my ~/bin/httpdebug :)
You can try sending a few curl requests to see that this really prints the headers and body.
curl -H "api-key: Foo" -X POST --form name=Khaja http://localhost:8080/ exec 3<>/dev/tcp/localhost/8080
echo -e "GET / HTTP/1.1\n\n" >&3
cat <&3A programming language will always be for programmers or at least enthusiasts.
Also I do not agree that bash is good for non-programmers. In order to make any more complicated thing work you have to learn a lot of syntax and language specific things. I have always found perl easier than bash to do anything remotely more complicated.
> Of course not.
It works just fine on Windows 10 with WSL.
$(command -v python2 || command -v python2.7 || command -v python2.6) -c
"import BaseHTTPServer, SimpleHTTPServer;
s = BaseHTTPServer.HTTPServer(('', {port}), SimpleHTTPServer.SimpleHTTPRequestHandler);
s.serve_forever()"Not that big.
> No.
Well, which is it ?
It can only accept one connection at a time because of the netcat command being used in a loop
Well, anyone can write that in a handful of lines in most languages.
$ nginx1. hardly a web server
2. hardly pure bash
of course writing a server of anything in pure bash is a tad bit difficult, as opposed to a client - bash can connect(), but can't bind() / listen() nor accept() unless, of course, you use something to expose these syscalls, but that opens a whole another can of worms...
Someone has actually went that far: http://ctypes.sh/.