| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/server.R |
| 3 |
\name{shinyServer} |
| 4 |
\alias{shinyServer} |
| 5 |
\title{Define Server Functionality} |
| 6 |
\usage{ |
| 7 |
shinyServer(func) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{func}{The server function for this application. See the details section |
| 11 |
for more information.} |
| 12 |
} |
| 13 |
\description{ |
| 14 |
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} |
| 15 |
|
| 16 |
Defines the server-side logic of the Shiny application. This generally |
| 17 |
involves creating functions that map user inputs to various kinds of output. |
| 18 |
In older versions of Shiny, it was necessary to call \code{shinyServer()} in |
| 19 |
the \code{server.R} file, but this is no longer required as of Shiny 0.10. |
| 20 |
Now the \code{server.R} file may simply return the appropriate server |
| 21 |
function (as the last expression in the code), without calling |
| 22 |
\code{shinyServer()}. |
| 23 |
|
| 24 |
Call \code{shinyServer} from your application's \code{server.R} |
| 25 |
file, passing in a "server function" that provides the server-side logic of |
| 26 |
your application. |
| 27 |
|
| 28 |
The server function will be called when each client (web browser) first loads |
| 29 |
the Shiny application's page. It must take an \code{input} and an |
| 30 |
\code{output} parameter. Any return value will be ignored. It also takes an |
| 31 |
optional \code{session} parameter, which is used when greater control is |
| 32 |
needed. |
| 33 |
|
| 34 |
See the \href{https://shiny.rstudio.com/tutorial/}{tutorial} for more |
| 35 |
on how to write a server function. |
| 36 |
} |
| 37 |
\examples{ |
| 38 |
\dontrun{ |
| 39 |
# A very simple Shiny app that takes a message from the user |
| 40 |
# and outputs an uppercase version of it. |
| 41 |
shinyServer(function(input, output, session) { |
| 42 |
output$uppercase <- renderText({ |
| 43 |
toupper(input$message) |
| 44 |
}) |
| 45 |
}) |
| 46 |
|
| 47 |
|
| 48 |
# It is also possible for a server.R file to simply return the function, |
| 49 |
# without calling shinyServer(). |
| 50 |
# For example, the server.R file could contain just the following: |
| 51 |
function(input, output, session) { |
| 52 |
output$uppercase <- renderText({ |
| 53 |
toupper(input$message) |
| 54 |
}) |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
\keyword{internal} |