2009-11-09 17:09:51 -05:00
|
|
|
require 'sinatra/base'
|
|
|
|
require 'rack'
|
|
|
|
|
2009-11-04 17:32:35 -05:00
|
|
|
class TestApp < Sinatra::Base
|
2009-11-05 11:35:45 -05:00
|
|
|
set :root, File.dirname(__FILE__)
|
|
|
|
set :static, true
|
2009-11-04 17:32:35 -05:00
|
|
|
|
|
|
|
get '/' do
|
|
|
|
'Hello world!'
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/foo' do
|
|
|
|
'Another World'
|
|
|
|
end
|
2009-11-04 18:34:11 -05:00
|
|
|
|
|
|
|
get '/with_html' do
|
|
|
|
erb :with_html
|
|
|
|
end
|
2009-11-14 09:11:29 -05:00
|
|
|
|
2009-11-05 11:35:45 -05:00
|
|
|
get '/with_js' do
|
|
|
|
erb :with_js
|
|
|
|
end
|
2009-11-14 09:11:29 -05:00
|
|
|
|
2009-11-04 17:32:35 -05:00
|
|
|
get '/with_simple_html' do
|
|
|
|
erb :with_simple_html
|
|
|
|
end
|
2009-11-07 19:13:16 -05:00
|
|
|
|
2009-11-14 09:11:29 -05:00
|
|
|
get '/with_scope' do
|
|
|
|
erb :with_scope
|
|
|
|
end
|
|
|
|
|
2009-11-07 19:13:16 -05:00
|
|
|
get '/form' do
|
|
|
|
erb :form
|
|
|
|
end
|
|
|
|
|
2009-11-12 13:02:00 -05:00
|
|
|
post '/redirect' do
|
|
|
|
redirect '/redirect_again'
|
|
|
|
end
|
|
|
|
|
2009-11-12 12:58:27 -05:00
|
|
|
get '/redirect' do
|
|
|
|
redirect '/redirect_again'
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/redirect_again' do
|
|
|
|
redirect '/landed'
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/landed' do
|
|
|
|
"You landed"
|
|
|
|
end
|
|
|
|
|
2009-11-07 19:13:16 -05:00
|
|
|
post '/form' do
|
2009-11-14 04:44:46 -05:00
|
|
|
'<pre id="results">' + params[:form].to_yaml + '</pre>'
|
2009-11-07 19:13:16 -05:00
|
|
|
end
|
2009-11-17 17:36:27 -05:00
|
|
|
|
|
|
|
get '/form/get' do
|
|
|
|
'<pre id="results">' + params[:form].to_yaml + '</pre>'
|
|
|
|
end
|
2009-11-12 11:07:43 -05:00
|
|
|
|
|
|
|
post '/upload' do
|
|
|
|
params[:form][:document][:tempfile].read
|
|
|
|
end
|
2009-11-07 19:13:16 -05:00
|
|
|
end
|
2009-11-09 17:09:51 -05:00
|
|
|
|
|
|
|
if __FILE__ == $0
|
|
|
|
Rack::Handler::Mongrel.run TestApp, :Port => 8070
|
|
|
|
end
|