Re:Shinatra – A simple bash web server
by minhajuddin on Wednesday November 23, 2016 @04:36AM
(#13021319)
Many people here fail to realize, this is an excellent debugging server. I used to have a server to print out the body and headers of requests when building an api to make sure things were going (the right headers and request body) out as expected https://github.com/minhajuddin/httpdebug/blob/master/app.go.
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/
Re:Shinatra – A simple bash web server
by kowdermeister on Wednesday November 23, 2016 @04:22AM
(#13021263)
I think the point here is to demonstrate that one might think that web servers are mystical beasts (true) but after all, they "just" return a HTTP header and some content.
Re:Shinatra – A simple bash web server
by foobarchu on Wednesday November 23, 2016 @04:45PM
(#13026027)
It doesn't demonstrate that very well, then. This simply delegates all of the basic server responsibilities to netcat. Where do you draw the line between 'bash web server' and simply invoking another program?
Re:Shinatra – A simple bash web server
by z3t4 on Wednesday November 23, 2016 @05:01AM
(#13021438)
Bash (shell-script) is a very powerful language, but a bit too complicated for the non-programmer (computer hacker). Then we got Perl, but it is also a bit too complicated. Now we have JavaScript doing the same thing, but also JavaScript (ES6) is now getting more complicated. I wonder is there a rule that says a (scripting) language for non-programmers will eventually either die or end up being too complicated for non-programmers ?
Re:Shinatra – A simple bash web server
by z3t4 on Wednesday November 23, 2016 @06:56AM
(#13021917)
A small amount of pessimism is healthy, but something being really simple is often preferable. A key here is good abstraction. Take for example a file system, witch is very easy to use, but still useful for computer experts.
Re:Shinatra – A simple bash web server
by yoz-y on Wednesday November 23, 2016 @05:31AM
(#13021544)
For me the scripting language for non-programmers looks more like Automator (the GUI) or Workflow - its iOS counterpart.
A 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.
Re:Shinatra – A simple bash web server
by arpa on Wednesday November 23, 2016 @04:08AM
(#13021222)
not to be that guy, but that's
1. 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...
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.
A 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.
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.
1. 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/.