Created
December 6, 2011 19:55
-
-
Save allometry/1439674 to your computer and use it in GitHub Desktop.
Little Snoop
This file contains 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 '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