Skip to content

Instantly share code, notes, and snippets.

@steadweb
Forked from mattmarcello/gist:295f0d22670299dd86cd
Last active August 29, 2015 14:07
Show Gist options
  • Save steadweb/1d8df88396398d5af49a to your computer and use it in GitHub Desktop.
Save steadweb/1d8df88396398d5af49a to your computer and use it in GitHub Desktop.

What do you know about Sinatra?

(1) Implement code that satisifes the following request / response pattern.

# request: GET '/matt'
# response: "Hello matt.  Do you mind if I call you ttam?"

# your code here

(2) Implement code that satisfies the following request / response pattern.

# request: GET to '/add?x=40&y=2'
# response: "42"

# your code here

(3)

Describe in words what the following code will do after a GET request to '/'

require 'sinatra'

get '/' do
  redirect '/hot'
end

get '/hot' do
  redirect '/potato'
end

get '/potato' do
  redirect 'http://google.com'
end
# your words can go here.

(4) Assuming a static image of a lemur exists in a public folder as lemur.png and the following server.rb...

#server.rb
get '/lemur.png' do
  "I am a Lemur.  Feed me rice."
end

What will be the response to a `GET request to '/lemur.png'?

# your answer goes here

(5)

What will be the response to a GET request to '/fun_times/4'

require 'sinatra'

get '/*' do
  "sup tho"
end

get '/fun_times/:num' do
  "fun " * params[:num]
end
# your answer here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment