htmlrubyimagesinatrapublic-folders

Sinatra serving images in HTML


So I currently have a very simple Sinatra server. I have a public folder that has css, js, and images as folders within it. In my view when I try to do something like <img src="/images/blah.png">, I get a 404 response. I thought the default of the public folder is public. I feel like I'm not including something or doing something stupid. I am using bootstrap and the css & js files are served fine. It isn't clear to me why I'm getting this 404 with the images?

This is how I'm running my application

#!/usr/bin/env ruby
$: << File.dirname(__FILE__)
require 'load_test_ui.rb'

unless ARGV[0].nil?
  class LoadTestUI < Sinatra::Base
    set :port, ARGV[0]
  end
end

LoadTestUI.run!

Solution

  • It was indeed a stupid mistake; I wasn't URI encoding the source. When I changed the name to just blah.png, it rendered correctly!