Rserve.http.add.static | R Documentation |
Rserve.http.add.static
installs a new static handler to be used by the
HTTP/HTTPS servers. It will trigger only if the path prefix matches prefix
and will map the subsequent portion of the path in the request URL to a file
system location specified by path
. If the resulting item in the file system
is a directory, then index
(if set) will be appended to the path and served
instead (if it is a file).
Rserve.http.rm.all.statics
removes all static handlers from the current
R session.
Rserve.http.add.static(prefix, path, index = NULL, last = FALSE)
Rserve.http.rm.all.statics()
prefix |
string, path prefix for which this handler will be used |
path |
string, path in the filesystem used as root to serve the content |
index |
optional string, will be appended to the file system path if
the target is a directory (typical value is |
last |
logical, if |
The HTTP/HTTPS server supports both static and dynamic handlers. The typical use
is to invoke .http.request
function in R for dynamic handling, but it also
supports static maps of URL paths to file system locations. The static handlers
are checked first.
Rserve.http.add.static
installs a new static handler, adding it to the
list of handlers. The handlers are consulted in the order that they are added.
The static handler supports conditional GETs and relies on the file system modification times to determine if a file has been modified.
The return value is considered experimental and may change in the future: Integer, number of active handlers (which is the same as the index of this handler).
Simon Urbanek
run.Rserve
## standard handler serving all files in the current working directory
## and consults index.html in directories if no file is specified.
Rserve.http.add.static("/", getwd(), "index.html", TRUE)
## start the server with:
## run.Rserve(http.port=8080, qap=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.