Last active
          October 26, 2017 22:49 
        
      - 
      
 - 
        
Save jacaetevha/0c9b64c62d2fc30c05dd44f4090b5310 to your computer and use it in GitHub Desktop.  
    Sample Sinatra application
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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 | 
  
    
      This file contains hidden or 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
    
  
  
    
  | <!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 --> | 
  
    
      This file contains hidden or 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
    
  
  
    
  | 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