Created
February 19, 2013 23:53
-
-
Save ichabodcole/4991398 to your computer and use it in GitHub Desktop.
Simple rack file loader.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FileLoadingApp | |
def call(env) | |
m = nil | |
headers = {'content-type'=>'text/html'} | |
r = Rack::Request.new(env) | |
path = r.path.slice(1, r.path.size) | |
puts path | |
File.open(path, 'rt') do |f| | |
m = [200, headers, [f.read]] | |
puts m | |
end | |
return m unless m.nil? | |
return [404, headers, ["Not Found!"]] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment