gp_plumb: Launch a webserver via plumber to serve data

View source: R/plumb.R

gp_plumbR Documentation

Launch a webserver via plumber to serve data

Description

Launch a webserver via plumber to serve data

Usage

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

gp_plumb_front()

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)
}

ATFutures/geoplumber documentation built on July 4, 2023, 12:18 a.m.