gpt4 book ai didi

ruby - 如何为 Rack 静态站点编写 config.ru?

转载 作者:太空宇宙 更新时间:2023-11-03 18:20:39 26 4
gpt4 key购买 nike

我的config.ru

require 'rack'
use Rack::Static, :root => '_site'

但是当我运行 rackup 时出现错误

/usr/local/share/gems/gems/rack-1.5.2/lib/rack/builder.rb:133:in `to_app': missing run or map statement (RuntimeError)

我想将文件夹 _site_ 中的文件托管在根 URL 上

最佳答案

Rack::Static是一个使用 Rack::File 的中间件,这是一个应用程序。如果你所做的只是提供静态文件,你可以直接运行 Rack::File:

# note 'run' not 'use'
run Rack::File.new('_site')

关于ruby - 如何为 Rack 静态站点编写 config.ru?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19078015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com