Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (27 sloc) 0.758 kB
require "singleton"
require "webrick";
class SimpleHTTPServer
include Singleton
include WEBrick
def start(dir, options)
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
mime_types.store 'js', 'application/javascript'
options={
:Port => 24680,
:MimeTypes => mime_types
}.merge(options)
stop
@http_server = HTTPServer.new(options) unless @http_server
@http_server_thread = Thread.new do
@http_server.mount("/",HTTPServlet::FileHandler, dir, {
:FancyIndexing => true
});
@http_server.start
end
end
def stop
@http_server.shutdown if @http_server
@http_server = nil
@http_server_thread.kill if @http_server_thread && @http_server_thread.alive?
end
end
Jump to Line
Something went wrong with that request. Please try again.