Send browser images

How can web-server written on Ruby, send *.ico, *.jpg, *.bmp etc files
to browser.
I try:


server=TCPServer.new(80)
session=server.accept
request=session.gets

str=nil
File.open(page,“rb”) do |sd|
if str==nil then str=sd.sysread(1) else str+=sd.sysread(1) end
end

session.puts str

but it doesn’t work.

born in USSR wrote:

How can web-server written on Ruby, send *.ico, *.jpg, *.bmp etc files
to browser.
I try:


server=TCPServer.new(80)
session=server.accept
request=session.gets

str=nil
File.open(page,“rb”) do |sd|
if str==nil then str=sd.sysread(1) else str+=sd.sysread(1) end
end

session.puts str

but it doesn’t work.

sorry, my question is very stupid, i understand that i read not full
file.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs