M
Michael Buffington
So I thought I had CGI in Ruby figured out, but I'm stumped on the following:
I want use Ruby to dynamically serve an image. The image tag would
look like <img src="file.rb?id=200">, where 200 is the id for an
image.
So here's what I have (I'm trading embarrassment for guidance):
require "cgi"
cgi = CGI.new("html4")
cgi.out('image/png')
File.read('200.png')
Now, I'm pretty sure I'm not reading the file right, but what I seem
to be stuck on first is getting my MIME type right. When hitting the
CGI, I can't get Content-Type to come back as 'image/png'. It's always
'text/html'.
Any tips?
I want use Ruby to dynamically serve an image. The image tag would
look like <img src="file.rb?id=200">, where 200 is the id for an
image.
So here's what I have (I'm trading embarrassment for guidance):
require "cgi"
cgi = CGI.new("html4")
cgi.out('image/png')
File.read('200.png')
Now, I'm pretty sure I'm not reading the file right, but what I seem
to be stuck on first is getting my MIME type right. When hitting the
CGI, I can't get Content-Type to come back as 'image/png'. It's always
'text/html'.
Any tips?