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
)

Arguments

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 http://127.0.0.1 to FALSE.

background

run the R process in the background using callr, defaults to TRUE.

Value

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.

See also

Examples

{ 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) }
#> Creating directory: /tmp/RtmptyG4FH/gp
#> To build/run app, set working directory to: /tmp/RtmptyG4FH/gp
#> Standard output from create-react-app works. #> You can run gp_ functions from directory: /tmp/RtmptyG4FH/gp #> To build the front end run: gp_build() #> To run the geoplumber app: gp_plumb() #> Happy coding.
#> WARNING: #> Looks like geoplumber was not built, serveing API only. #> To serve the front end run gp_build() first.
#> Loading required package: RCurl