Ruby/Network/mongrel Web Server
Материал из Wiki.crossplatform.ru
Mongrel::HttpServer.new specifies the number of threads to open to handle requests.
require "rubygems" require "mongrel" class BasicServer < Mongrel::HttpHandler def process(request, response) response.start(200) do |headers, output| headers["Content-Type"] = "text/html" output.write("<html><body><h1>Hello!</h1></body></html>") end end end s = Mongrel::HttpServer.new("0.0.0.0", "1234",20) s.register("/", BasicServer.new) s.run.join
Mongrel server that will return a simple HTML page when http://localhost:s loaded
require "rubygems" require "mongrel" class BasicServer < Mongrel::HttpHandler def process(request, response) response.start(200) do |headers, output| headers["Content-Type"] = "text/html" output.write("<html><body><h1>Hello!</h1></body></html>") end end end s = Mongrel::HttpServer.new("0.0.0.0", "1234") s.register("/", BasicServer.new) s.run.join