This class represents a web server running one application. Multiple servers can be running at the same time.
See also
Server() and PipeServer().
Super class
httpuv::Server -> WebServer
Methods
Method new()
Initialize a new WebServer object
Create a new WebServer object. app is an httpuv application
object as described in startServer().
Usage
WebServer$new(host, port, app, quiet = FALSE)Arguments
hostThe host name or IP address to bind the server to.
portThe port number to bind the server to.
appAn httpuv application object as described in
startServer().quietIf TRUE, suppresses output from the server.
Examples
## ------------------------------------------------
## Method `WebServer$new`
## ------------------------------------------------
if (FALSE) { # \dontrun{
# Create a simple app
app <- function(req) {
list(
status = 200L,
headers = list('Content-Type' = 'text/plain'),
body = "Hello, world!"
)
}
# Create a server
server <- WebServer$new("127.0.0.1", 8080, app)
} # }