runStaticServer | R Documentation |
runStaticServer()
provides a convenient interface to start a server to host
a single static directory, either in the foreground or the background.
runStaticServer(
dir = getwd(),
host = "127.0.0.1",
port = NULL,
...,
background = FALSE,
browse = interactive()
)
dir |
The directory to serve. Defaults to the current working directory. |
host |
A string that is a valid IPv4 address that is owned by this
server, or |
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 macOS, port numbers smaller than 1024 require root privileges. |
... |
Arguments passed on to
|
background |
Whether to run the server in the background. By default,
the server runs in the foreground and blocks the R console. You can stop
the server by interrupting it with When |
browse |
Whether to automatically open the served directory in a web
browser. Defaults to |
Starts a server on the specified host and port. By default the
server runs in the foreground and is accessible at http://127.0.0.1:7446
.
When background = TRUE
, the server
object is returned invisibly.
runServer()
provides a similar interface for running a dynamic
app server. Both runStaticServer()
and runServer()
are built on top of
startServer()
, service()
and stopServer()
. Learn more about httpuv
servers in startServer()
.
website_dir <- system.file("example-static-site", package = "httpuv")
runStaticServer(dir = website_dir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.