Server | R Documentation |
The package is based on httpuv::. It is designed to host static resources such as html, javascript, css, etc along with specific route requests to perform various R based actions or respond with various content(i.g. JSON strings, images, etc). The server is designed to work in a local host environment (i.e. url = 127.0.0.1) as part of an html/javascript project that needs a link to R language capabilities and its associated packages.
Class provides an http server that connects R language resources with javascript applications.
index_path
A string that defines the full directory path to an index.html
file defining the server's
root path (i.e. "\"). The root html file is assumed to be named "index.html".
port
An integer that defines the port number for the server. The default is 8080.
routes
A vector of RserverPkg::Route
objects that define the request paths that the server will respond to.
Each RserverPkg::Route
object should define the path, callback function that optionally returns content, and the
content's MIME content type. The callback function can be defined to receive a RserverPkg::Request
object argument.
static_paths
A named list that defines the locations of static resources (.css, .html, .js files) for hosting by the server. The list name is the web path (e.g. "/content") and the value is the full directory path to the resources (e.g. F:/web_server/content).
new()
Defines the classes' public fields
Server$new(index_path = NULL, port = 8080, routes = NULL, static_paths = NULL)
index_path
A string that defines the full directory path to an index.html
file defining the server's
root path (i.e. "\").
port
An integer that defines the port number for the server.
routes
A vector of RserverPkg::Route
objects that define the request paths that the server will respond to.
static_paths
A named list that defines the locations of static resources (.css, .html, .js files) for hosting by the server.
start()
Start the server
Server$start()
stop()
Stop the server
Server$stop()
list_servers()
List the current servers
Server$list_servers()
clone()
The objects of this class are cloneable with this method.
Server$clone(deep = FALSE)
deep
Whether to make a deep clone.
Rick Dean
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.