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
|
# File 'lib/clayoven/httpd.rb', line 5
def self.start
port = 8000
callback = Proc.new do |req, res|
if %r{^/$} =~ req.path_info
res.set_redirect WEBrick::HTTPStatus::Found, "index.html"
end
if %r{^/([^.]*)$} =~ req.path_info
res.set_redirect WEBrick::HTTPStatus::Found, "#{$1}.html"
end
end
server = WEBrick::HTTPServer.new(:Port => port,
:RequestCallback => callback,
:DocumentRoot => Dir.pwd)
puts "clayoven serving at: http://localhost:#{port}"
trap(:INT) { server.shutdown }
server.start
end
|