| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/runapp.R |
| 3 |
\name{runApp} |
| 4 |
\alias{runApp} |
| 5 |
\title{Run Shiny Application} |
| 6 |
\usage{ |
| 7 |
runApp( |
| 8 |
appDir = getwd(), |
| 9 |
port = getOption("shiny.port"), |
| 10 |
launch.browser = getOption("shiny.launch.browser", interactive()), |
| 11 |
host = getOption("shiny.host", "127.0.0.1"), |
| 12 |
workerId = "", |
| 13 |
quiet = FALSE, |
| 14 |
display.mode = c("auto", "normal", "showcase"), |
| 15 |
test.mode = getOption("shiny.testmode", FALSE) |
| 16 |
) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{appDir}{The application to run. Should be one of the following: |
| 20 |
\itemize{ |
| 21 |
\item A directory containing \code{server.R}, plus, either \code{ui.R} or |
| 22 |
a \code{www} directory that contains the file \code{index.html}. |
| 23 |
\item A directory containing \code{app.R}. |
| 24 |
\item An \code{.R} file containing a Shiny application, ending with an |
| 25 |
expression that produces a Shiny app object. |
| 26 |
\item A list with \code{ui} and \code{server} components. |
| 27 |
\item A Shiny app object created by \code{\link[=shinyApp]{shinyApp()}}. |
| 28 |
}} |
| 29 |
|
| 30 |
\item{port}{The TCP port that the application should listen on. If the |
| 31 |
\code{port} is not specified, and the \code{shiny.port} option is set (with |
| 32 |
\code{options(shiny.port = XX)}), then that port will be used. Otherwise, |
| 33 |
use a random port between 3000:8000, excluding ports that are blocked |
| 34 |
by Google Chrome for being considered unsafe: 3659, 4045, 5060, |
| 35 |
5061, 6000, 6566, 6665:6669 and 6697. Up to twenty random |
| 36 |
ports will be tried.} |
| 37 |
|
| 38 |
\item{launch.browser}{If true, the system's default web browser will be |
| 39 |
launched automatically after the app is started. Defaults to true in |
| 40 |
interactive sessions only. The value of this parameter can also be a |
| 41 |
function to call with the application's URL.} |
| 42 |
|
| 43 |
\item{host}{The IPv4 address that the application should listen on. Defaults |
| 44 |
to the \code{shiny.host} option, if set, or \code{"127.0.0.1"} if not. See |
| 45 |
Details.} |
| 46 |
|
| 47 |
\item{workerId}{Can generally be ignored. Exists to help some editions of |
| 48 |
Shiny Server Pro route requests to the correct process.} |
| 49 |
|
| 50 |
\item{quiet}{Should Shiny status messages be shown? Defaults to FALSE.} |
| 51 |
|
| 52 |
\item{display.mode}{The mode in which to display the application. If set to |
| 53 |
the value \code{"showcase"}, shows application code and metadata from a |
| 54 |
\code{DESCRIPTION} file in the application directory alongside the |
| 55 |
application. If set to \code{"normal"}, displays the application normally. |
| 56 |
Defaults to \code{"auto"}, which displays the application in the mode given |
| 57 |
in its \code{DESCRIPTION} file, if any.} |
| 58 |
|
| 59 |
\item{test.mode}{Should the application be launched in test mode? This is |
| 60 |
only used for recording or running automated tests. Defaults to the |
| 61 |
\code{shiny.testmode} option, or FALSE if the option is not set.} |
| 62 |
} |
| 63 |
\description{ |
| 64 |
Runs a Shiny application. This function normally does not return; interrupt R |
| 65 |
to stop the application (usually by pressing Ctrl+C or Esc). |
| 66 |
} |
| 67 |
\details{ |
| 68 |
The host parameter was introduced in Shiny 0.9.0. Its default value of |
| 69 |
\code{"127.0.0.1"} means that, contrary to previous versions of Shiny, only |
| 70 |
the current machine can access locally hosted Shiny apps. To allow other |
| 71 |
clients to connect, use the value \code{"0.0.0.0"} instead (which was the |
| 72 |
value that was hard-coded into Shiny in 0.8.0 and earlier). |
| 73 |
} |
| 74 |
\examples{ |
| 75 |
\dontrun{ |
| 76 |
# Start app in the current working directory |
| 77 |
runApp() |
| 78 |
|
| 79 |
# Start app in a subdirectory called myapp |
| 80 |
runApp("myapp") |
| 81 |
} |
| 82 |
|
| 83 |
## Only run this example in interactive R sessions |
| 84 |
if (interactive()) { |
| 85 |
options(device.ask.default = FALSE) |
| 86 |
|
| 87 |
# Apps can be run without a server.r and ui.r file |
| 88 |
runApp(list( |
| 89 |
ui = bootstrapPage( |
| 90 |
numericInput('n', 'Number of obs', 100), |
| 91 |
plotOutput('plot') |
| 92 |
), |
| 93 |
server = function(input, output) { |
| 94 |
output$plot <- renderPlot({ hist(runif(input$n)) }) |
| 95 |
} |
| 96 |
)) |
| 97 |
|
| 98 |
|
| 99 |
# Running a Shiny app object |
| 100 |
app <- shinyApp( |
| 101 |
ui = bootstrapPage( |
| 102 |
numericInput('n', 'Number of obs', 100), |
| 103 |
plotOutput('plot') |
| 104 |
), |
| 105 |
server = function(input, output) { |
| 106 |
output$plot <- renderPlot({ hist(runif(input$n)) }) |
| 107 |
} |
| 108 |
) |
| 109 |
runApp(app) |
| 110 |
} |
| 111 |
} |