Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Created May 9, 2012 16:33
Show Gist options
  • Save jhchabran/2646331 to your computer and use it in GitHub Desktop.
Save jhchabran/2646331 to your computer and use it in GitHub Desktop.
require 'sinatra/base'
require 'sinatra/json'
module Photograph
class Service < ::Sinatra::Base
helpers Sinatra::JSON
def artist
unless @artist
puts "CWEIR"
@artist = Artist.new
end
@artist
end
get '/' do
json :version => Photograph::VERSION
end
get '/shoot' do
options = {:url => params["url"],
:x => params["x"].to_i,
:y => params["y"].to_i,
:w => params["w"].to_i,
:h => params["h"].to_i}
artist.shoot! options do |image|
send_file image.path, :type => :png
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment