require 'webrick' include WEBrick dir = Dir::pwd port = 1234 authenticate = Proc.new do |req, res| HTTPAuth.basic_auth(req, res, '') do |user, password| user == 'foo' && password == 'bar' end end s = HTTPServer.new(:Port => port, :ServerType => Daemon) s.mount('/', HTTPServlet::FileHandler, dir, :FancyIndexing => true, :HandlerCallback => authenticate # Hook up the authentication proc. ) trap('INT') { s.shutdown } s.start
You need to create an account or log in to post comments to this site.