Skip to content

Instantly share code, notes, and snippets.

@rbq
Created November 4, 2013 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbq/7308392 to your computer and use it in GitHub Desktop.
Save rbq/7308392 to your computer and use it in GitHub Desktop.
Animal
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
get '/:animal' do
@all_animals = ['Cat', 'Dog']
@animal = params[:animal] if @all_animals.include? params[:animal]
erb :index
end
__END__
@@ index
<h1><%= @animal || 'Unknown animal' %></h1>
<% if @animal %>
<img src="/<%= @animal %>.jpeg"/>
<% end %>
<% @all_animals.each do |animal| %>
<a href="/<%= animal %>"><%= animal %></a>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment