Skip to content

Instantly share code, notes, and snippets.

View codepants's full-sized avatar

Han Boon Kiat codepants

  • Crown Digital
View GitHub Profile
@codepants
codepants / gist:5307165
Created April 4, 2013 02:12
ruby-hash cheapo 'CouchDb'
require 'webrick'
require 'json'
DB = {}
class Simple < WEBrick::HTTPServlet::AbstractServlet
def do_GET request, response
p = request.path.split "/"
response.status, response['Content-Type'], response.body = 200, 'text/plain', p.length < 4 ? DB[p[2].to_sym].to_json : DB[p[2].to_sym][p[3].to_sym].to_json
end
end
class SimpleP < WEBrick::HTTPServlet::AbstractServlet