-
-
Save jacobbednarz/00279c2749e202a82d6d to your computer and use it in GitHub Desktop.
This file contains 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 'sinatra/base' | |
IMAGES = [ | |
{ title: "matrix", url: "http://i0.kym-cdn.com/entries/icons/original/000/009/889/Morpheus2.jpg" }, | |
{ title: "google", url: "http://i0.kym-cdn.com/news_feeds/icons/original/000/006/501/google-search.jpg" }, | |
{ title: "skywalking", url: "http://i2.kym-cdn.com/photos/images/newsfeed/000/295/090/9de.jpg" } | |
] | |
class App < Sinatra::Base | |
get '/images' do | |
@images = IMAGES | |
end | |
get '/images/:index' do |index| | |
@image = IMAGE[index] | |
end | |
end |
This file contains 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
macbookpro: ~/code/sinatra-app | |
→ ls -la | |
total 16 | |
drwxr-xr-x 4 jacob staff 136 29 Dec 15:36 . | |
drwxr-xr-x 12 jacob staff 408 29 Dec 15:10 .. | |
-rw-r--r-- 1 jacob staff 491 29 Dec 16:06 app.rb | |
-rw-r--r-- 1 jacob staff 25 29 Dec 15:14 config.ru | |
macbookpro: ~/code/sinatra-app | |
→ rackup | |
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require': ./app.rb:4: odd number list for Hash (SyntaxError) | |
{ title: "matrix", url: "http://i0.kym... | |
^ | |
./app.rb:4: syntax error, unexpected ':', expecting '}' | |
{ title: "matrix", url: "http://i0.kym... | |
^ | |
./app.rb:4: syntax error, unexpected ',', expecting $end | |
{ title: "matrix", url: "http://i0.kym-cdn.com/e... | |
^ | |
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require' | |
from /Users/jacob/code/sinatra-app/config.ru:2 | |
from /Users/jacob/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' | |
from /Users/jacob/.rvm/gems/ruby-1.9.2-p320/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' | |
from /Users/jacob/code/sinatra-app/config.ru:1:in `new' | |
from /Users/jacob/code/sinatra-app/config.ru:1 |
This file contains 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
macbookpro: ~/code/sinatra-app | |
→ ruby -rubygems app.rb | |
/Users/jacob/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- sinatra (LoadError) | |
from /Users/jacob/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' | |
from app.rb:1:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, here is the working version:
https://gist.github.com/4405233