vignettes/files/apis/05-01-scope.R

# Global code; gets executed at plumb() time.
counter <- 0

#* @get /
function() {
  # Only gets evaluated when this endpoint is requested.
  counter <<- counter + 1
}

Try the plumber2 package in your browser

Any scripts or data that you put into this service are public.

plumber2 documentation built on Jan. 20, 2026, 5:06 p.m.