emptygif
言語: 日本語

すべての言語・フレームワーク

plumber R

/pixel.gif へのリクエストに空の GIF を返す、plumber 用の R スニペット。GIF は起動時に一度だけデコードします。

plumber R

インストール
install.packages("plumber")
ファイル
plumber.R
実行
Rscript -e 'plumber::pr_run(plumber::pr("plumber.R"), port = 8080)'
# plumber.R
gif <- jsonlite::base64_dec("R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")

#* @get /pixel.gif
#* @serializer contentType list(type = "image/gif")
function(res) {
  res$setHeader("Cache-Control", "no-store")
  gif
}

このスニペットは実行し、返されたバイト列を照合しました。

確認

curl -sI http://localhost:8080/pixel.gif

公式サイト: plumber