Skip to content

Instantly share code, notes, and snippets.

Created Nov 4, 2013
What would you like to do?
#!/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
@@ 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