Serving static files with Rack
30 Mar 2022You can use a Proc
like this to serve static files.
# config.ru
map '/' do
path = '/index.html'
default_homepage = File.read(path)
app = proc do |env|
[200, { 'Content-Type' => 'text/html' }, [default_homepage]]
# last argument needs to be an array
end
run app
end
The proc
keyword is the equivalent to Proc.new
.