require "rubygems" require "sinatra/base" class RackApp < Sinatra::Base use_in_file_templates! get "/" do erb :home end get "/go" do erb :go end get "/internal_redirect" do redirect "/" end get "/external_redirect" do redirect "http://google.com" end get "/absolute_redirect" do redirect URI.join(request.url, "foo").to_s end get "/foo" do "spam" end post "/go" do @user = params[:name] @email = params[:email] erb :hello end end __END__ @@ layout
visit there
@@ go @@ helloHello, <%= @user %>
Your email is: <%= @email %>