Created
November 4, 2013 20:02
-
-
Save rbq/7308392 to your computer and use it in GitHub Desktop.
Animal
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
#!/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