pedro mg
By: a guest | Nov 17th, 2007 | Syntax:
Ruby | Size: 0.47 KB | Hits: 45 | Expires: Never
class Static < R '/static/(.+)'
MIME_TYPES = { '.css' => 'text/css', '.js' => 'text/javascript',
'.jpg' => 'image/jpeg', '.png' => 'image/png' }
def get(file)
@headers['Content-Type'] = MIME_TYPES[file[('/\.\w+$/')]] || 'text/plain'
unless file.include?".."
@headers['X-Sendfile'] = "#{File.expand_path(File.dirname(__FILE__))}/static/#{file}"
else
@status = "403"
"403 - Path Not Found!"
end
end