Getting Started with Sinatra – Minimalist Ruby Web Framework
I’ve found a very cool new Ruby web framework in the vein of Camping. It’s called Sinatra, and it’s a very minimalist approach to writing RESTful applications.
A quick snippet of code to give you a feel for just how minimal things can get:
require 'rubygems' require 'sinatra' get '/' do "Hello world" end
Or for something more exciting with sessions:
require 'rubygems' require 'sinatra' set_option :sessions, true get '/' do session["foo"] ||= 0 session["foo"] += 1 "Hello world, you've asked for foo: #{session["foo"].to_s} number of times" end
As you can see, it’s dead simple to write a trivial app. Over the next few blog posts, I’m going to get a “semantic pastebin” up and running, complete with database access, backend jobs, form handling, and probably some other cool stuff.
Leave a Reply