5

here でplumber説明されているように、静的ファイルを提供したいと思います。ルートなどを含むファイルは次のとおりです。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.html404 エラーが発生します。

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

オブジェクトを印刷するrと、パブリック パスが定義されているように見えます。

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

私が間違っているアイデアはありますか?

4

1 に答える 1

1

残念ながら、静的ファイル サーバーの注釈の名前を黙って変更し、(明らかに) ドキュメントを更新しませんでした。

ここに実例を追加しました: https://github.com/trestletech/plumber/tree/master/inst/examples/05-staticですが、新しい注釈は@assetsであり、 ではありません@static。まもなくドキュメントを更新します。

于 2016-04-18T15:14:32.637 に答える