Created
April 21, 2011 12:44
-
-
Save hannahwhy/934406 to your computer and use it in GitHub Desktop.
recreation of the listerine server
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 'redis' | |
| require 'sinatra' | |
| # to do: | |
| # (1) checkout expiration | |
| # (2) /introduce (not sure what it does) | |
| # (3) support vidid harvesters | |
| # more? | |
| R = Redis.new | |
| get '/introduce/:username/:external_ip' do | |
| # ? | |
| end | |
| get '/getID/:username' do | |
| R.multi do |r| | |
| vidid = r.spop 'gv_done' | |
| r.sadd 'gv_processing', vidid | |
| end | |
| vidid | |
| end | |
| get '/finishVid/:username/:id/:size/:hash' do | |
| vidid = params['id'] | |
| data = { | |
| 'size' => params['size'], | |
| 'hash' => params['hash'], | |
| 'user' => params['username'] | |
| } | |
| R.multi do |r| | |
| r.srem 'gv_processing', vidid | |
| r.sadd 'gv_downloaded', vidid | |
| r.hmset vidid, data | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment