Class: Veewee::Web

Inherits:
Object
  • Object
show all
Includes:
WEBrick
Defined in:
lib/veewee/web.rb

Defined Under Namespace

Classes: FileServlet

Class Method Summary collapse

Class Method Details

.wait_for_request(filename, options = {:timeout => 10, :web_dir => "", :port => 7125}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/veewee/web.rb', line 27

def self.wait_for_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125})  
  
  webrick_logger=WEBrick::Log.new("/dev/null", WEBrick::Log::INFO)
  
  web_dir=options[:web_dir]
  filename=filename
  s= HTTPServer.new(
    :Port => options[:port],
    :Logger => webrick_logger,
    :AccessLog => webrick_logger
  )
  s.mount("/#{filename}", FileServlet,File.join(web_dir,filename))
  trap("INT"){
      s.shutdown
      puts "Stopping webserver"
      exit
    }
  s.start
end