Skip to content

Instantly share code, notes, and snippets.

@chooh
Created December 28, 2010 15:48

Revisions

  1. chooh created this gist Dec 28, 2010.
    15 changes: 15 additions & 0 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # This is the root of our app
    @root = File.expand_path(File.join(File.dirname(__FILE__), "www"))

    run Proc.new { |env|
    # Extract the requested path from the request
    req = Rack::Request.new(env)
    index_file = File.join(@root, req.path_info, "index.html")

    if File.exists?(index_file)
    # Rewrite to index
    req.path_info += "index.html"
    end
    # Pass the request to the directory app
    Rack::Directory.new(@root).call(env)
    }