Last active
December 15, 2015 03:59
-
-
Save lfborjas/5198574 to your computer and use it in GitHub Desktop.
prueba de concepto de app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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