Ruby 使用机架的静态文件服务
我有一段代码:Ruby 使用机架的静态文件服务,ruby,rack,cuba,Ruby,Rack,Cuba,我有一段代码: require "cuba" require "mote" require "mote/render" Cuba.plugin(Mote::Render) Cuba.use Rack::Static, # urls: %w[/index], root: File.expand_path("./public", __dir__) Cuba.define do on(root) do render("index", title: "Welcome")
require "cuba"
require "mote"
require "mote/render"
Cuba.plugin(Mote::Render)
Cuba.use Rack::Static,
# urls: %w[/index],
root: File.expand_path("./public", __dir__)
Cuba.define do
on(root) do
render("index", title: "Welcome")
end
end
我正试图将文件放在名为“index.html”的公用文件夹(与我正在运行的文件位于同一目录)中,但我的网站上出现了一个错误,说找不到该文件
No such file or directory @ rb_sysopen - /root/views/index.html.mote
有什么帮助吗?提前谢谢 Cuba尝试渲染模板,因此您可以将文件重命名为.mote,它应该渲染为ok,或者使用类似以下内容:
res.headers["Content-Type"] = "text/html; charset=utf-8"
res.write(IO.read('/path/to/your/file.html'))
非常清楚渲染函数的工作原理。Cuba尝试渲染模板,因此您可以将文件重命名为.mote,并且它应该渲染为ok,或者使用类似以下内容:
res.headers["Content-Type"] = "text/html; charset=utf-8"
res.write(IO.read('/path/to/your/file.html'))
非常清楚渲染函数的工作原理。Cuba尝试渲染模板,因此您可以将文件重命名为.mote,并且它应该渲染为ok,或者使用类似以下内容:
res.headers["Content-Type"] = "text/html; charset=utf-8"
res.write(IO.read('/path/to/your/file.html'))
非常清楚渲染函数的工作原理。Cuba尝试渲染模板,因此您可以将文件重命名为.mote,并且它应该渲染为ok,或者使用类似以下内容:
res.headers["Content-Type"] = "text/html; charset=utf-8"
res.write(IO.read('/path/to/your/file.html'))
非常清楚渲染功能的工作原理。您还可以设置自己的自定义路由,以便在不使用Rack::Static的情况下为css/js提供服务
on 'css', extension('css') do
res['Content-Type'] = 'text/css'
res.write File.read(req.path)
end
您还可以为css/js服务设置自己的自定义路由,而无需使用Rack::Static
on 'css', extension('css') do
res['Content-Type'] = 'text/css'
res.write File.read(req.path)
end
您还可以为css/js服务设置自己的自定义路由,而无需使用Rack::Static
on 'css', extension('css') do
res['Content-Type'] = 'text/css'
res.write File.read(req.path)
end
您还可以为css/js服务设置自己的自定义路由,而无需使用Rack::Static
on 'css', extension('css') do
res['Content-Type'] = 'text/css'
res.write File.read(req.path)
end
是的,喜欢他们的是,喜欢他们的是,喜欢他们的是,喜欢他们的