create_server: Function provides an http server that connects R language...

create_serverR Documentation

Function provides an http server that connects R language resources with javascript applications.

Description

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. As per the httpuv:: documentation, the server can be stopped by calling httpuv::stopServer(server=name_of_server). Also to list the current running server(s) call httpuv::listServers().

Usage

create_server(
  index_path = NULL,
  port = 8080,
  routes = NULL,
  static_paths = NULL
)

Arguments

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

Value

A httpuv::WebServer

Author(s)

Rick Dean


deandevl/RserverPkg documentation built on June 9, 2022, 9:44 p.m.