Sha256: b1023e3ac5fd819b96b41b4e1230d91663743d5f3eabc3be77da6cd0467cc45e
Contents?: true
Size: 570 Bytes
Versions: 50
Compression:
Stored size: 570 Bytes
Contents
class SampleServer # This is the root of our app @root = File.expand_path(File.dirname(__FILE__)) + "/sample_site" def self.app Proc.new { |env| # Extract the requested path from the request path = Rack::Utils.unescape(env['PATH_INFO']) index_file = @root + "#{path}/index.html" if File.exists?(index_file) # Return the index [200, {'Content-Type' => 'text/html'}, File.read(index_file)] else # Pass the request to the directory app Rack::Directory.new(@root).call(env) end } end end
Version data entries
50 entries across 50 versions & 1 rubygems