Skip to content

Instantly share code, notes, and snippets.

@allometry
Created December 6, 2011 19:55
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 allometry/1439674 to your computer and use it in GitHub Desktop.
Save allometry/1439674 to your computer and use it in GitHub Desktop.
Little Snoop
require 'sinatra'
require 'mongo_mapper'
require 'uri'
set :haml, :format => :html5
mongo_uri = URI.parse(ENV['MONGOHQ_URL'])
MongoMapper.connection = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
MongoMapper.database = mongo_uri.path.gsub(/^\//, '')
class Victim
include MongoMapper::Document
key :name, String
key :ip, String
key :created, Time
end
get '/' do
"Nothing to see here, move along..."
end
get '/snitch/:name' do
victim = Victim.create(:name => "#{params[:name]}", :ip => request.ip, :created => Time.now)
send_file 'catalyst.png'
end
get '/victims' do
victims = Victim.all
haml :victims, :locals => { :victims => victims }
end
get '/victims/delete/:id' do
Victim.find("#{params[:id]}").destroy
redirect to('/victims')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment