frankfurter/lib/app.rb
2012-11-21 13:18:16 +00:00

31 lines
442 B
Ruby

require_relative 'snapshot'
require 'sinatra'
require 'sinatra/jsonp'
require 'yajl'
set :root, File.expand_path('..', File.dirname(__FILE__))
helpers do
def base
params[:base] || 'EUR'
end
end
get '/' do
File.read File.join 'public', 'index.html'
end
get '/latest' do
jsonp Snapshot
.last
.with_base(base)
.to_hash
end
get '/:date' do |date|
jsonp Snapshot
.new(date)
.with_base(base)
.to_hash
end