require 'webrick' # The :AccessLog configuration takes an array. # Each element of the array should be # a two-element array where the first element # is the stream (or anything responding to <<) and # the second element is the access log format. # Please see webrick/accesslog.rb for available formats. access_log_stream = File.open('C:\\Documents and Settings\\madann\\My Documents\\access.log', 'w') access_log = [ [ access_log_stream, WEBrick::AccessLog::COMBINED_LOG_FORMAT ] ] DocumentRoot = 'C:\\Documents and Settings\\madann\\My Documents\\Public_html\\'; HTTPPort = 8008 begin d = Dir.open(DocumentRoot) rescue puts "Creating Documentroot" mkdir DocumentRoot end class DownloadHandler < WEBrick::HTTPServlet::AbstractServlet def do_get(req,resp) p "req : ",req p "resp : ",resp end def go_post(req,resp) resp end end s = WEBrick::HTTPServer.new( :Port => HTTPPort, :DocumentRoot => DocumentRoot, :FancyIndexing => true #:Logger => WEBrick::Log.new('download.log'), #:AccessLog => access_log ) s.mount("/cgi-bin", WEBrick::HTTPServlet::FileHandler, "C:\\Documents and Settings\\madann\\My Documents\\Public_html\\cgi-bin\\", {:FancyIndexing=>true}) trap("INT"){ s.shutdown } s.start
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
httpd.rb (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» rsrcmeter for TxD in ruby http textdrive disk usage access_log bandwidth quota
» rsrcmeter v2 in ruby http textdrive disk usage access_log bandwidth quota
» Authenticated Digest for Net... in ruby http md5
» Typo under lighttpd in lighttpd ruby rails typo ruby-fcgi
» password hash script in ruby password
» Stable sort in ruby sort
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails