4 ms·
If you do get the chance, check out Ruby and Sinatra. The whole source is only roughly 2000 lines of code, but it gives you just a very minimal level of abstrac
by steveklabnik 17y ago
If you do get the chance, check out Ruby and Sinatra. The whole source is only roughly 2000 lines of code, but it gives you just a very minimal level of abstraction over HTTP.
Here's "hello world" in Sinatra:
require ‘rubygems’
require ’sinatra’
get ‘/hi’ do
“Hello World!”
end
... That's it. It's cool stuff.
- mixmax 17y agoAnd here it is in PHP: echo "Hello world"; One line. Just saying....
- cmelbye 17y agoExcept not at all. Your example doesn't handle a clean URL like "/hi" (it would be something like "/hi.php" at best in PHP). Furthermore, it doesn't force the GET http request type, which is a major part of the Sinatra microframework. I can setup a Ruby script that outputs "Hello World", but that would miss the point entirely. EDIT: Also, the original ruby example could be condensed to one line as well: get "/hi" { "Hello world" } Run with ruby -rsinatra script.rb
- armandososa 17y agoOr try Microbus if(get("hi")){ echo "Hello World"; } http://github.com/soska/microbus http://github.com/soska/microbus (I know… I always feel bad with self promotion)