require 'webrick' include WEBrick class UberServlet < HTTPServlet::AbstractServlet def do_GET(req, res) id = req.query['id'] # Get GET/POST params like that. res['content-type'] = 'text/html' res.status = 200 res.body = some_text end alias :do_POST :do_GET end # "Mount" the servlet. server = HTTPServer.new(:Port => 1234) server.mount('/some/path', UberServlet) # Handle signals. %w(INT TERM).each do |signal| trap(signal) { server.shutdown } end server.start
You need to create an account or log in to post comments to this site.