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

Version Path
cobweb-1.2.1 spec/samples/sample_server.rb
cobweb-1.2.0 spec/samples/sample_server.rb
cobweb-1.1.0 spec/samples/sample_server.rb
cobweb-1.0.29 spec/samples/sample_server.rb
cobweb-1.0.28 spec/samples/sample_server.rb
cobweb-1.0.27 spec/samples/sample_server.rb
cobweb-1.0.26 spec/samples/sample_server.rb
cobweb-1.0.25 spec/samples/sample_server.rb
cobweb-1.0.24 spec/samples/sample_server.rb
cobweb-1.0.23 spec/samples/sample_server.rb
cobweb-1.0.22 spec/samples/sample_server.rb
cobweb-1.0.21 spec/samples/sample_server.rb
cobweb-1.0.20 spec/samples/sample_server.rb
cobweb-1.0.19 spec/samples/sample_server.rb
cobweb-1.0.18 spec/samples/sample_server.rb
cobweb-1.0.17 spec/samples/sample_server.rb
cobweb-1.0.16 spec/samples/sample_server.rb
cobweb-1.0.15 spec/samples/sample_server.rb
cobweb-1.0.12 spec/samples/sample_server.rb
cobweb-1.0.11 spec/samples/sample_server.rb