Sha256: 1000185300d1e28dcf872de3a6d8d4472139303fe32db39e318145d4f48481cb

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

require 'sinatra/base'
require 'sinatra/json'

module Photograph
  # Preload the chrome instance
  Artist.browser

  class Service < ::Sinatra::Base
    helpers Sinatra::JSON

    get '/' do
      json :version => Photograph::VERSION
    end

    get '/shoot' do
      artist = Artist.new :url => params["url"],
                          :x   => params["x"].to_i,
                          :y   => params["y"].to_i,
                          :w   => params["w"].to_i,
                          :h   => params["h"].to_i,
                          :wait => params["wait"].to_f,
                          :selector => params["selector"]

      artist.shoot!

      send_file artist.image.path,
        :type => :png

      artist.clean!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
photograph-0.0.1 lib/photograph/service.rb