Create a local web application based on R's internal httpd.
Usage
new_app(name, handler, open = interactive(), host = "127.0.0.1", port = NULL)
stop_app(name = names(.proxy$apps))Arguments
- name
App name (a character string). Use
name = ''to serve the app at the root URLhttp://host:PORT/via the proxy. Ifnameis non-empty, the app is served directly by R's internal httpd at/custom/name/. Each name must be unique; callingnew_app()with an existing name replaces that app. Forstop_app(), a character vector of app names to stop; defaults to all running apps.- handler
A function with signature
function(path, query, post, headers)that handles HTTP requests and returns a response list.- open
Whether to open the app URL in a browser, or a function to open it. In non-interactive sessions this also controls whether the call blocks: passing
open = FALSEexplicitly suppresses both browser-opening and blocking.- host
Bind address for the proxy (
"127.0.0.1"or"0.0.0.0"). Only used whenname = ''.- port
Candidate proxy ports when
name = ''. The first available port is selected (falling back torandom_port()if needed). Ignored whenname != ''.
Details
new_app() has two modes:
name = '': start an app behind a lightweight proxy athttp://host:PORT/, forwarding to R's internal httpd path/custom/xfun:PORT/.name != '': register a legacy app directly on R's internal httpd athttp://127.0.0.1:BACKEND/custom/name/(compatible with older versions).
stop_app() deregisters one or more running apps.