Created
December 28, 2009 20:57
-
-
Save Musfuut/264941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
data = "none" | |
before do | |
content_type 'text/plain', :charset => 'utf-8' | |
request.env['PATH_INFO'].gsub!(/\/$/,'') | |
end | |
get '/' do | |
"Hello World" | |
end | |
notfound do | |
"Huh? Where was that again? Hmm, let me look around and get back to you." | |
end | |
# This will show the contents of the variable 'data' from above | |
get '/show' do | |
"data is set to '#{data}'\n" | |
end | |
# This sets the contents of the variable 'data' to "one", use /show to display it. | |
get '/one' do | |
data = "one" | |
"data is set to '#{data}'\n" | |
end | |
# This sets the contents of the variable 'data' to "two", use /show to display it. | |
get '/two' do | |
data = "two" | |
"data is set to '#{data}'\n" | |
end | |
# This sets the contents of the variable 'data' to "three", use /show to display it. | |
get '/three' do | |
data = "three" | |
"data is set to '#{data}'\n" | |
end | |
# This... breaks... it sets the variable 'data' and even displays the correct | |
# message, however it appears to be working with a private instance of 'data' | |
# and will not affect the value of 'data' from above, nor show up with /show | |
# | |
get '/dynamic/:word' do | |
data = params[:word] | |
"data is set to '#{data}'\n" | |
end | |
# However this works as intended with /setword?word=monkeys | |
get '/setword' do | |
data = params[:word] | |
"data is set to '#{data}'\n" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment