Created
October 30, 2010 04:47
-
-
Save kn0ll/654959 to your computer and use it in GitHub Desktop.
small ruby server to show a random tinygrab image
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 'open-uri' | |
get '/' do | |
tryImg | |
end | |
def tryImg | |
rand = '' | |
1.upto(4) { rand << rand(36).to_s(36) } | |
open('http://grab.by/%s' % rand) do |c| | |
if c.content_type == 'image/png' | |
content_type c.content_type | |
c.read | |
else | |
tryImg | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment