You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
357 B
22 lines
357 B
require 'sinatra/base'
|
|
require_relative 'cpi_fetcher'
|
|
|
|
class App < Sinatra::Base
|
|
get '/' do
|
|
current_cpi = fetcher.cpi
|
|
halt 502 unless current_cpi
|
|
|
|
expires 300, :public, :must_revalidate
|
|
content_type :text
|
|
"#{current_cpi}\n"
|
|
end
|
|
|
|
run! if app_file == $PROGRAM_FILE
|
|
|
|
private
|
|
|
|
def fetcher
|
|
@fetcher ||= CPIFetcher.new
|
|
end
|
|
end
|