我正在尝试从本教程中获得一些信息:http://m.onkey.org/2008/11/18/ruby-on-rack-2-rack-builder
基本上,我希望有一个文件config.ru
,告诉rack读取当前目录,这样我就可以像访问简单的apache服务器一样访问所有文件,还可以使用index.html file...is读取默认根目录。有什么方法可以做到吗?
我当前的config.ru
如下所示:
run Rack::Directory.new('')
#this would read the directory but it doesn't set the root to index.html
map '/' do
file = File.read('index.html')
run Proc.new {|env| [200, {'Content-Type' => 'text/html'}, file] }
end
#using this reads the index.html mapped as the root but ignores the other files in the directory
所以我不知道该怎么做...
我也按照教程示例进行了尝试,但thin
不能正常启动。
builder = Rack::Builder.new do
run Rack::Directory.new('')
map '/' do
file = File.read('index.html')
run Proc.new {|env| [200, {'Content-Type' => 'text/html'}, file] }
end
end
Rack::Handler::Thin.run builder, :port => 3000
提前感谢
https://stackoverflow.com/questions/3863781
复制相似问题