Class: Vbox::Web::FileServlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- Vbox::Web::FileServlet
- Defined in:
- lib/vbox/web.rb
Instance Method Summary collapse
- #do_GET(request, response) ⇒ Object
-
#initialize(server, localfile) ⇒ FileServlet
constructor
A new instance of FileServlet.
Constructor Details
#initialize(server, localfile) ⇒ FileServlet
Returns a new instance of FileServlet.
9 10 11 12 13 |
# File 'lib/vbox/web.rb', line 9 def initialize(server,localfile) super(server) @server=server @localfile=localfile end |
Instance Method Details
#do_GET(request, response) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vbox/web.rb', line 14 def do_GET(request,response) response['Content-Type']='text/plain' response.status = 200 puts "Serving file #{@localfile}" displayfile=File.open(@localfile,'r') content=displayfile.read() response.body=content #If we shut too fast it might not get the complete file sleep 2 @server.shutdown end |