emptygif
語言: 繁體中文

所有語言和框架

plumber R

適用於 plumber 的 R 程式碼片段,以空 GIF 回應對 /pixel.gif 的請求,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