Permalink
Browse files

Adding a rackup so thin can serve the site

  • Loading branch information...
1 parent 664e207 commit b3977572515e70e6962eaf7c7514ea48fb46beb6 Zach Moazeni committed May 8, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 config.ru
View
@@ -0,0 +1,15 @@
+@root = File.expand_path(File.dirname(__FILE__))
+
+run 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
+}

0 comments on commit b397757

Please sign in to comment.