/ Published in: Ruby
Simple HTTP server daemon (webrick).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/ruby require 'webrick' include WEBrick def start_webrick(config = {}) config.update(:Port => 5001) server = HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each do |signal| trap(signal) { server.shutdown } end server.start end start_webrick(:DocumentRoot => 'path-to-document-root', :ServerType => Daemon)