Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ac77b01230
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (20 sloc) 0.672 kb
require "sinatra"
require "active_support/all"
require "json"
require "digest"
require "highcharts_server/cuty_capt"
module HighchartsServer
def self.root
Pathname.new(File.dirname(__FILE__)).join("..").expand_path
end
class Server < Sinatra::Base
post "/charts" do
chart_options = JSON.parse(CGI.unescape(request.env["rack.input"].read))
hash = Digest::MD5.hexdigest(chart_options.to_json)
image_path = HighchartsServer.root.join("tmp", "charts-#{hash}-#{Time.now.to_i}-#{$$}.png").to_s
cuty_capt = CutyCapt.new(chart_options)
cuty_capt.write_to(image_path)
send_file image_path, :type => "image/png"
end
end
end
Jump to Line
Something went wrong with that request. Please try again.