5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/moft/commands/serve.rb', line 5
def self.process(options)
require 'webrick'
include WEBrick
destination = options['destination']
FileUtils.mkdir_p(destination)
mime_types_file = File.expand_path('../mime.types', File.dirname(__FILE__))
mime_types = WEBrick::HTTPUtils::load_mime_types(mime_types_file)
fh_option = WEBrick::Config::FileHandler
fh_option[:NondisclosureName] = ['.ht*','~*']
s = HTTPServer.new(
:Port => options['port'],
:BindAddress => options['host'],
:MimeTypes => mime_types
)
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination, fh_option)
t = Thread.new { s.start }
trap("INT") { s.shutdown }
t.join()
end
|