By: Maksim Surguy & Cesar Acosta require 'sinatra‘ get ‘/' do "Hello World!" end
Web application framework in Ruby DSL* for defining RESTful HTTP actions Fast Fun! Not Rails Not MVC *Domain specific Language
gem install sinatra vi my_app.rb set :port, 3000 require ‘sinatra’ get ‘/’ do ‘Hello World’ end ruby my_app.rb
Gems More Condensed Changes to the App require to restart the server gem install shotgun Run => shotgun my_app.rb
vi my_app2.rb require ‘sinatra’ set :port, 3000 get '/hello/:name' do "Hello #{params[:name]}" end ruby my_app2.rb
get '/' do.. show something.. end post '/' do.. create something.. end put '/' do.. update something.. end delete '/' do.. annihilate something.. end options '/' do.. appease something.. end
Supports practically every template engine in Ruby: HAML ERB Erubis Builder Nokogiri Sass Less Liquid And many, many more !!! ( require ‘haml‘ get ‘/' do haml :index end Renders./views/index.haml
APIs Web services (fast !!!) Quick minimal applications Lean web development (Largely static sites with some dynamic content) Deploy on Heroku!
Heroku GitHub services Engine Yard Apartment Therapy Many Others More examples at :
sinatra/ sinatra/ services-with-sinatra-and-heroku services-with-sinatra-and-heroku