Skip to content

Instantly share code, notes, and snippets.

@lfborjas
Last active December 15, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lfborjas/5198574 to your computer and use it in GitHub Desktop.
Save lfborjas/5198574 to your computer and use it in GitHub Desktop.
prueba de concepto de app
require 'sinatra'
require 'rest-client'
require 'json'
API_KEY = "satan"
#Asumiendo que existe un cliente que llama este endpoint así:
#$.post("myapp.heroku.com/image", {image: base64ified_image }).done(function(data){ console.log(data.image_url)})
#hostealo aquí
#https://devcenter.heroku.com/articles/rack
post '/image' do
raw_response_from_imgur = RestClient.post(
"http://imgur.com/api/upload.json",
key: API_KEY,
image: params["image"]
)
response_from_imgur = JSON.parse(raw_response_from_imgur.body)
content_type :json
{image_url: response_from_imgur["link"]}.to_json
end
gem 'sinatra'
gem 'rest-client'
gem 'json' #probablemente innecesaria
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment