Posted by pedro mg on Sun 18 Nov 04:09
report abuse | View followups from zimbatm | download | new post
- 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
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.