rrpcServer {shinylight}R Documentation

Makes and starts a server for serving R calculations

Description

It will serve files from the app directories specified by appDirs. If a file is requested that is not in one of those directories, the files in Shinylight's own inst/www directory will be served. Some paths have special meanings: / returns /index.html, /lang/ is redirected to /locales/<language-code>/ depending on the language selected in the request's Accept-Language header (that is, the browser's language setting) and the availability of the file requested. A POST request to /init with a data parameter will return /index.html, except that if the file has a line containing shinylight_initial_data = then this line with be replaced with a line initializing shinylight_initial_data to the data passed. This is used in shinylight-framework to permit linking to a framework app with specific data preloaded – the text should be as is downloaded with the "Save Data" button. Of course, this is available to non-framework apps, too.

Usage

rrpcServer(
  interface,
  host = "0.0.0.0",
  port = NULL,
  appDirs = NULL,
  root = "/",
  initialize = NULL,
  testFunction = NULL
)

Arguments

interface

List of functions to be served. The names of the elements are the names that the client will use to call them.

host

Interface to listen on (default is '0.0.0.0', that is, all interfaces)

port

Port to listen on

appDirs

List of directories in which to find static files to serve

root

Root of the app on the server (with trailing slash)

initialize

A json string or list (that will be converted to a JSON string) to be passed to the JavaScript as initial data. For non-framework apps, the index.html must contain a line containing var shinylight_initial_data=, which will be replaced with code that sets shinylight_initial_data to this supplied JSON string.

testFunction

Function to be called if the /test endpoint is requested. If the function returns successfully, a 200 status will be returned. If not, a 500 status will be returned.

Value

The server object, can be passed to slStop


[Package shinylight version 1.2 Index]