vignettes/files/apis/07-04-file-safe.R

#* This is an example of an endpoint which
#* checks user input.
#* @get /
function(file) {
  # Strip all "non-word" characters from user input
  sanitizedFile <- gsub("\\W", "", file)

  path <- file.path("./datasets", sanitizedFile)
  readLines(path)
}
rstudio/plumber documentation built on April 12, 2025, 7:33 p.m.