Guest User

Untitled

a guest
Dec 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. require 'bundler/setup'
  2. Bundler.require
  3.  
  4. class Application < Sinatra::Base
  5. get '/assets/:file' do
  6. env['PATH_INFO'].gsub!("/assets","")
  7. asset_handler.call(env)
  8. end
  9.  
  10. get '/' do
  11. erb :index
  12. end
  13.  
  14. private
  15. def project_root
  16. @project_root ||= File.expand_path File.dirname(__FILE__)
  17. end
  18.  
  19. def asset_handler
  20. @asset_handler ||= create_asset_handler
  21. end
  22.  
  23. def create_asset_handler
  24. handler = Sprockets::Environment.new(project_root)
  25. handler.cache = Sprockets::Cache::FileStore.new("/tmp")
  26. handler.append_path(File.join(project_root, 'src/javascripts'))
  27. handler.append_path(File.join(project_root, 'src/stylesheets'))
  28. handler
  29. end
  30. end
  31.  
  32. run Application
Add Comment
Please, Sign In to add comment