resourcePaths: Resource Publishing

Description Usage Arguments Details See Also Examples

View source: R/server-resource-paths.R

Description

Add, remove, or list directory of static resources to Shiny's web server, with the given path prefix. Primarily intended for package authors to make supporting JavaScript/CSS files available to their components.

Usage

1
2
3
4
5
addResourcePath(prefix, directoryPath)

resourcePaths()

removeResourcePath(prefix)

Arguments

prefix

The URL prefix (without slashes). Valid characters are a-z, A-Z, 0-9, hyphen, period, and underscore. For example, a value of 'foo' means that any request paths that begin with '/foo' will be mapped to the given directory.

directoryPath

The directory that contains the static resources to be served.

Details

Shiny provides two ways of serving static files (i.e., resources):

  1. Static files under the www/ directory are automatically made available under a request path that begins with /.

  2. addResourcePath() makes static files in a directoryPath available under a request path that begins with prefix.

The second approach is primarily intended for package authors to make supporting JavaScript/CSS files available to their components.

Tools for managing static resources published by Shiny's web server:

See Also

singleton()

Examples

1
2
3
4
5
6
7
addResourcePath('datasets', system.file('data', package='datasets'))
resourcePaths()
removeResourcePath('datasets')
resourcePaths()

# make sure all resources are removed
lapply(names(resourcePaths()), removeResourcePath)

shiny documentation built on Jan. 26, 2021, 1:06 a.m.