Launch a webserver via plumber to serve data
gp_plumb( run = TRUE, port = 8000, file = "R/plumber.R", front = FALSE, host = "127.0.0.1", background = TRUE )
| run | should plumber run the server or return it as an object |
|---|---|
| port | to serve from |
| file | location of plumber.R file used by plumber |
| front | should geoplumber start the front dev server? Defaults |
| host | host to pass to plumber default |
| background | run the R process in the background using callr,
defaults to |
an instance of plumber::plumb if run is set to FALSE,
a process id from callr::r_bg to easily destroy if parameter
background is default TRUE.
{ d <- file.path(tempdir(), "gp") gp_create(d) old <- setwd(d) ps <- gp_plumb() ps Sys.sleep(1) # just in case ps require(RCurl) webpage <- getURL("http://localhost:8000") webpage <- readLines(tc <- textConnection(webpage)); close(tc) tail(webpage) ps$kill() setwd(old) unlink(d, recursive = TRUE) }#>#>#> #> #> #> #>#> #> #>#>