Created
December 29, 2011 07:23
-
-
Save dhruvasagar/1532564 to your computer and use it in GitHub Desktop.
Sinatra File Server for serving Videos
This file contains 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
APP_ROOT = File.expand_path('.') | |
require 'sinatra' | |
get '*' do | |
mimetype = `file -ib #{File.join(APP_ROOT, params[:splat].join)}`.gsub(/\n/,"") | |
content_type mimetype | |
send_file File.join(APP_ROOT, params[:splat].join) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment