Sinatra (C) 2007 By Blake Mizerany = Classy web-development dressed in a DSL == Install! sudo gem install sinatra -y == Use! I'm going to move quick. I'll let you drool at your own pace. - Create a file called lyrics.rb (or any name you like) - Add require 'rubygems' require 'sinatra' - Run (yes, with just ruby) % ruby lyrics.rb == Sinata has taken the stage on port 4567! - Take a moment and view the default page http://localhost:4567. Go ahead and bask in it's glory. * Notice: * It didn't create any page to show you that default page (just a cool thing to see, that's all) * There was nothing generated other than a log file * Sinatra is a really cool name for a web-framework that's a DSL - Modify lyrics.rb by adding: get '/' do 'Hello World' end - Refresh (no need to restart Sinatra): http://localhost:4567 - Modify again (then refresh): get '/' do <<-HTML
HTML end post '/' do "Hello #{params[:name] || 'World'}!" end - Homework: Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same. Do them inline and as template files.