Skip to content

Instantly share code, notes, and snippets.

@chrisconley
Created November 14, 2009 21:12
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 chrisconley/234786 to your computer and use it in GitHub Desktop.
Save chrisconley/234786 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'net/http'
require 'uri'
class ImageModeration
include DataMapper::Resource
property :id, Integer, :serial=>true
property :image_url, Text
property :created_at, DateTime
property :results, Text
property :offensive, String
property :finished_at, DateTime
# Send image details to Houdini
def self.start
moderation = self.create(:created_at => Time.now, :image_url => image_url)
data = {
'image_url' => 'http://images.google.com/images/life_hpp7.jpg',
'postback_url' => "http://YOUR_DOMAIN.com/image_moderation_results",
'client_data' => moderation.id}
url = URI.parse('http://gohoudini.com/moderate_image')
Net::HTTP.post_form(url, data)
end
end
# Receive image moderation answer from Houdini
post '/image_moderation_results' do
moderation = ImageModeration.get(request.POST["client_data"])
moderation.update_attributes(:results => request.POST, :offensive => request.POST["offensive"], :finished_at => Time.now)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment