shinyServer: Define Server Functionality

View source: R/server.R

shinyServerR Documentation

Define Server Functionality

Description

[Superseded]

Defines the server-side logic of the Shiny application. This generally involves creating functions that map user inputs to various kinds of output. In older versions of Shiny, it was necessary to call shinyServer() in the server.R file, but this is no longer required as of Shiny 0.10. Now the server.R file may simply return the appropriate server function (as the last expression in the code), without calling shinyServer().

Call shinyServer from your application's server.R file, passing in a "server function" that provides the server-side logic of your application.

The server function will be called when each client (web browser) first loads the Shiny application's page. It must take an input and an output parameter. Any return value will be ignored. It also takes an optional session parameter, which is used when greater control is needed.

See the tutorial for more on how to write a server function.

Usage

shinyServer(func)

Arguments

func

The server function for this application. See the details section for more information.

Examples

## Not run: 
# A very simple Shiny app that takes a message from the user
# and outputs an uppercase version of it.
shinyServer(function(input, output, session) {
  output$uppercase <- renderText({
    toupper(input$message)
  })
})


# It is also possible for a server.R file to simply return the function,
# without calling shinyServer().
# For example, the server.R file could contain just the following:
function(input, output, session) {
  output$uppercase <- renderText({
    toupper(input$message)
  })
}

## End(Not run)

rstudio/shiny documentation built on Nov. 8, 2024, 6 a.m.