Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

runServer

Run a server


Description

This is a convenience function that provides a simple way to call startServer, service, and stopServer in the correct sequence. It does not return unless interrupted or an error occurs.

Usage

runServer(host, port, app, interruptIntervalMs = NULL)

Arguments

host

A string that is a valid IPv4 or IPv6 address that is owned by this server, which the application will listen on. "0.0.0.0" represents all IPv4 addresses and "::/0" represents all IPv6 addresses.

port

A number or integer that indicates the server port that should be listened on. Note that on most Unix-like systems including Linux and Mac OS X, port numbers smaller than 1025 require root privileges.

app

A collection of functions that define your application. See startServer.

interruptIntervalMs

Deprecated (last used in httpuv 1.3.5).

Details

If you have multiple hosts and/or ports to listen on, call the individual functions instead of runServer.

See Also

Examples

## Not run: 
# A very basic application
runServer("0.0.0.0", 5000,
  list(
    call = function(req) {
      list(
        status = 200L,
        headers = list(
          'Content-Type' = 'text/html'
        ),
        body = "Hello world!"
      )
    }
  )
)

## End(Not run)

httpuv

HTTP and WebSocket Server Library

v1.6.1
GPL (>= 2) | file LICENSE
Authors
Joe Cheng [aut], Winston Chang [aut, cre], RStudio, PBC [cph], Hector Corrada Bravo [ctb], Jeroen Ooms [ctb], Andrzej Krzemienski [cph] (optional.hpp)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.