Skip to content

Instantly share code, notes, and snippets.

@ichabodcole
Created February 19, 2013 23:53
Show Gist options
  • Save ichabodcole/4991398 to your computer and use it in GitHub Desktop.
Save ichabodcole/4991398 to your computer and use it in GitHub Desktop.
Simple rack file loader.
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