Skip to content

Instantly share code, notes, and snippets.

@qrohlf
Last active August 29, 2015 14:10
Show Gist options
  • Save qrohlf/d1aa1783fc0f38637be2 to your computer and use it in GitHub Desktop.
Save qrohlf/d1aa1783fc0f38637be2 to your computer and use it in GitHub Desktop.
ruby imgur api example with Sinatra
# app.rb
# this is a simple Sinatra example app
# use bundler
require 'rubygems'
require 'bundler/setup'
# load all of the gems in the gemfile
Bundler.require
imgurClient = Imgur.new '5acc7208e8fa6fb'
get '/' do
img = Imgur::LocalImage.new('test.jpg', title: 'Test post please ignore')
uploaded = imgurClient.upload(img)
puts "uploaded: #{uploaded.link}"
"<img src='#{uploaded.link}' /><p>Uploaded to #{uploaded.link}</p>"
end
require './app'
run Sinatra::Application
ruby "2.1.4"
source 'https://rubygems.org'
gem 'sinatra', '>= 1.4.5'
gem 'imgur-api', require: 'imgur'
gem 'tux'
group :development do
gem 'sqlite3', '>= 1.3.9'
gem 'shotgun', '>= 0.9'
end
GEM
remote: https://rubygems.org/
specs:
bond (0.5.1)
httparty (0.13.3)
json (~> 1.8)
multi_xml (>= 0.5.2)
imgur-api (0.0.4)
httparty
json (1.8.1)
multi_xml (0.5.5)
rack (1.5.2)
rack-protection (1.5.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
ripl (0.7.1)
bond (~> 0.5.1)
ripl-multi_line (0.3.1)
ripl (>= 0.3.6)
ripl-rack (0.2.1)
rack (>= 1.0)
rack-test (~> 0.6.2)
ripl (>= 0.7.0)
shotgun (0.9)
rack (>= 1.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
sqlite3 (1.3.9)
tilt (1.4.1)
tux (0.3.0)
ripl (>= 0.3.5)
ripl-multi_line (>= 0.2.4)
ripl-rack (>= 0.2.0)
sinatra (>= 1.2.1)
PLATFORMS
ruby
DEPENDENCIES
imgur-api
shotgun (>= 0.9)
sinatra (>= 1.4.5)
sqlite3 (>= 1.3.9)
tux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment