mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
98a33bb304
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@21 19e92222-5c0b-0410-8929-a290d50e31e9
27 lines
715 B
Ruby
27 lines
715 B
Ruby
require 'mongrel'
|
|
require 'yaml'
|
|
|
|
class SimpleHandler < Mongrel::HttpHandler
|
|
def process(request, response)
|
|
response.start do |head,out|
|
|
head["Content-Type"] = "text/html"
|
|
out << "<html><body>Your request:<br />"
|
|
out << "<pre>#{request.params.to_yaml}</pre>"
|
|
out << "<a href=\"/files\">View the files.</a></body></html>"
|
|
end
|
|
end
|
|
end
|
|
|
|
if ARGV.length != 3
|
|
STDERR.puts "usage: simpletest.rb <host> <port> <docroot>"
|
|
exit(1)
|
|
end
|
|
|
|
h = Mongrel::HttpServer.new(ARGV[0], ARGV[1])
|
|
h.register("/", SimpleHandler.new)
|
|
h.register("/files", Mongrel::DirHandler.new(ARGV[2]))
|
|
h.run
|
|
|
|
puts "Mongrel running on #{ARGV[0]}:#{ARGV[1]} with docroot #{ARGV[2]}"
|
|
|
|
h.acceptor.join
|