Create a gist now

Instantly share code, notes, and snippets.

@oshow /app.rb
Created Nov 16, 2011

What would you like to do?
for Rubyist Magazine 0036
# encoding: utf-8
require 'rubygems'
require 'sinatra/base'
require 'sinatra/reloader'
require 'rack/rewrite'
require 'haml'
class App < Sinatra::Base
enable :inline_templates
enable :logging
configure :development do
set :server, "webrick"
register Sinatra::Reloader
end
use Rack::Rewrite do
rewrite %r{^/song_for/(.*)}, '/name/$1'
end
get '/' do
@title = "Top"
haml "My Way"
end
get '/name/:name' do
@name = params[:name]
@title = "Song for #{@name}"
haml "#{@name}'s Way"
end
end
App.run!
__END__
@@ layout
!!! 5
%html
%head
%title= @title
%body
%h1= @title
%div= yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment