【问题标题】:serving static files with plumber package - files not found (404)使用管道工包提供静态文件 - 找不到文件 (404)
【发布时间】:2016-04-18 07:41:07
【问题描述】:

我想使用plumber 提供静态文件,如here 所述。包含路线等的文件是server.R:

#* @get /files
function()
{
  return(dir("files"))
}

#* @static ./files
list() 

这应该使files 目录在路径/public 上可用。在files 中有一个文件index.html。运行上面的代码:

library(plumber)
r <- plumb("server.R")
r$run()

调用localhost:8000/files 返回:

["index.html"]

但是,调用 localhost:8000/public/index.html 会出现 404 错误:

{"error":["404 - Resource Not Found"]}

打印r 对象,公共路径似乎已定义:

> r
<plumber>
  Public:
    addAssets: function (dir, path = "/public", options = list()) 
    ...

有什么想法我哪里出错了吗?

【问题讨论】:

    标签: r plumber


    【解决方案1】:

    过失...我默默地重命名了静态文件服务器的注释并且(显然)从未更新过文档。

    我在这里添加了一个工作示例:https://github.com/trestletech/plumber/tree/master/inst/examples/05-static,但新注释是@assets,而不是@static。我会尽快更新文档。

    【讨论】:

      猜你喜欢
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 2019-01-12
      • 1970-01-01
      • 2015-11-30
      • 2017-02-18
      相关资源
      最近更新 更多