[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

WEBrick default index page

mitchell

6/10/2005 9:52:00 PM

Instead of using an index.html, index.rhtml, index.cgi, etc. as the
default page to load on localhost:[port], I was wondering if it was
possible to load a servlet instead (i.e. '/index'). I have looked at
the WEBrick source, but could not figure out how to do this (even like
trying to execute a request or response).

Any help would be greatly appreciated.

2 Answers

Ghislain MARY

6/10/2005 10:26:00 PM

0

Hi,

mitchell a écrit :
> Instead of using an index.html, index.rhtml, index.cgi, etc. as the
> default page to load on localhost:[port], I was wondering if it was
> possible to load a servlet instead (i.e. '/index'). I have looked at
> the WEBrick source, but could not figure out how to do this (even like
> trying to execute a request or response).
>
> Any help would be greatly appreciated.
>

I am not sure I really understood what you want to do but I think you
can do something like:

require 'webrick'

svr = WEBrick::HTTPServer.new(
:Port => 8080,
:BindAddress => 'localhost'
)

svr.mount_proc('/') { |req, res|
res.body = "This is not the default index!"
res['content-type'] = "text/plain"
}

trap("INT") { svr.shutdown }

svr.start


Or you can mount a servlet instead of a proc...

HTH

Ghislain


mitchell

6/11/2005 5:28:00 PM

0

Thank you, that worked. I do remember trying that earlier, but
something else had broken so I forgot about it.