Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Last active October 26, 2017 22:49
Show Gist options
  • Save jacaetevha/0c9b64c62d2fc30c05dd44f4090b5310 to your computer and use it in GitHub Desktop.
Save jacaetevha/0c9b64c62d2fc30c05dd44f4090b5310 to your computer and use it in GitHub Desktop.
Sample Sinatra application
get '/' do
erb :audio
end
get '/flac' do
send_file '../relative/path/to/file.flac', type: 'audio/flac', disposition: 'inline'
end
get '/mp3' do
send_file '/absolute/path/to/file.mp3', type: 'audio/mp3', disposition: 'inline'
end
<!DOCTYPE html>
<html>
<body>
<h1>MP3 File</h1>
<audio controls>
<source src='/mp3' />
Your browser does not support the audio element.
</audio>
<h1>FLAC File</h1>
<audio controls>
<source src='/flac' />
Your browser does not support the audio element.
</audio>
</body>
</html>
<!-- this file exists in views/audio.erb -->
require 'sinatra'
require 'erb'
require './app'
run Sinatra::Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment