質問編集履歴
1
追記しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -59,4 +59,61 @@
|
|
59
59
|
<%= ENV['QUERY_STRING'] %>
|
60
60
|
</body>
|
61
61
|
</html>
|
62
|
+
```
|
63
|
+
|
64
|
+
追記です
|
65
|
+
erbを使いたかったのとかなり前のプログラムだったので付録(デフォルト)のwebrickでは無く自前のwebrickを書いたのですがそれが原因の気がします...
|
66
|
+
```lang-<ruby>
|
67
|
+
##myserver.rb(自前)
|
68
|
+
require 'webrick'
|
69
|
+
|
70
|
+
config = {
|
71
|
+
:Port => 8099,
|
72
|
+
:DocumentRoot => './',
|
73
|
+
}
|
74
|
+
|
75
|
+
WEBrick::HTTPServlet::FileHandler.add_handler("erb", WEBrick::HTTPServlet::ERBHandler)
|
76
|
+
|
77
|
+
server = WEBrick::HTTPServer.new(config)
|
78
|
+
|
79
|
+
server.config[:MimeTypes]["erb"] = "text/html"
|
80
|
+
|
81
|
+
trap(:INT) do
|
82
|
+
server.shutdown
|
83
|
+
end
|
84
|
+
|
85
|
+
server.start
|
86
|
+
```
|
87
|
+
##server.rb(デフォルト)
|
88
|
+
```lang-<ruby>
|
89
|
+
require 'webrick'
|
90
|
+
|
91
|
+
rrr = WEBrick::HTTPServlet::CGIHandler::Ruby
|
92
|
+
$ruby = $ruby || rrr
|
93
|
+
|
94
|
+
module WEBrick
|
95
|
+
module HTTPServlet
|
96
|
+
FileHandler.add_handler("rb", CGIHandler)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def start_webrick(config = {})
|
101
|
+
conf = {
|
102
|
+
:Port => 8080,
|
103
|
+
:BindAddress => '127.0.0.1',
|
104
|
+
:CGIInterpreter => $ruby,
|
105
|
+
}
|
106
|
+
config.update(conf)
|
107
|
+
server = WEBrick::HTTPServer.new(config)
|
108
|
+
yield server if block_given?
|
109
|
+
['INT', 'TERM'].each {|signal|
|
110
|
+
trap(signal) {server.shutdown}
|
111
|
+
}
|
112
|
+
server.start
|
113
|
+
end
|
114
|
+
|
115
|
+
start_webrick {|server|
|
116
|
+
cgi_dir = File.dirname( File.expand_path(__FILE__) )
|
117
|
+
server.mount("/", WEBrick::HTTPServlet::FileHandler, cgi_dir, {:FancyIndexing=>true})
|
118
|
+
}
|
62
119
|
```
|