Run a Shiny application from a URL — runUrl

v1.7.3|Source: R/run-url.R

Description

runUrl() downloads and launches a Shiny application that is hosted at a downloadable URL. The Shiny application must be saved in a .zip, .tar, or .tar.gz file. The Shiny application files must be contained in the root directory or a subdirectory in the archive. For example, the files might be myapp/server.r and myapp/ui.r. The functions runGitHub() and runGist() are based on runUrl(), using URL's from GitHub (https://github.com) and GitHub gists (https://gist.github.com), respectively.

runUrl(url, filetype = NULL, subdir = NULL, destdir = NULL, ...)

runGist(gist, destdir = NULL, ...)

runGitHub(
  repo,
  username = getOption("github.user"),
  ref = "HEAD",
  subdir = NULL,
  destdir = NULL,
  ...
)

Arguments

url

URL of the application.

filetype

The file type (".zip", ".tar", or ".tar.gz". Defaults to the file extension taken from the url.

subdir

A subdirectory in the repository that contains the app. By default, this function will run an app from the top level of the repo, but you can use a path such as "inst/shinyapp".

destdir

Directory to store the downloaded application files. If NULL (the default), the application files will be stored in a temporary directory and removed when the app exits

...

Other arguments to be passed to runApp(), such as port and launch.browser.

gist

The identifier of the gist. For example, if the gist is https://gist.github.com/jcheng5/3239667, then 3239667, '3239667', and 'https://gist.github.com/jcheng5/3239667' are all valid values.

repo

Name of the repository.

username

GitHub username. If repo is of the form "username/repo", username will be taken from repo.

ref

Desired git reference. Could be a commit, tag, or branch name. Defaults to "HEAD", which means the default branch on GitHub, typically "main" or "master".

Examples

## Only run this example in interactive R sessions
if (interactive()) {
  runUrl('https://github.com/rstudio/shiny_example/archive/main.tar.gz')

  # Can run an app from a subdirectory in the archive
  runUrl("https://github.com/rstudio/shiny_example/archive/main.zip",
    subdir = "inst/shinyapp/")
}
## Only run this example in interactive R sessions
if (interactive()) {
  runGist(3239667)
  runGist("https://gist.github.com/jcheng5/3239667")

  # Old URL format without username
  runGist("https://gist.github.com/3239667")
}

## Only run this example in interactive R sessions
if (interactive()) {
  runGitHub("shiny_example", "rstudio")
  # or runGitHub("rstudio/shiny_example")

  # Can run an app from a subdirectory in the repo
  runGitHub("shiny_example", "rstudio", subdir = "inst/shinyapp/")
}