Ruby / Sinatra - serving up css, javascript, or image files

前端 未结 2 1690
北恋
北恋 2020-12-14 00:56

What is the correct way to route your request through Sinatra so that it serves up the file with no processing? I\'m looking for the most common way people do this in the Si

相关标签:
2条回答
  • 2020-12-14 01:28

    Sinatra and Rails use the path public for static content - e.g., ./public/javascripts/. All files in these paths would then be served by the web server (e.g. Thin, Passenger), but without the need for /public in the URL (e.g. the file at #{my_app_root}/public/javascripts/application.js would be available via the Web at the URL http://#{my_domain}/javascripts/application.js).

    0 讨论(0)
  • 2020-12-14 01:32
    get '/notes/images/:file' do
      send_file('/root/dev/notes/images/'+params[:file], :disposition => 'inline')
    end
    
    0 讨论(0)
提交回复
热议问题