Last active
September 1, 2016 02:14
-
-
Save mndrake/44dc767b67701bc990079bf096c47e4e to your computer and use it in GitHub Desktop.
R Shiny with URL parameters (https://beta.rstudioconnect.com/content/1583/?foo=1&bar=hello)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| shinyServer(function(input, output, session) { | |
| # Return the components of the URL in a string: | |
| output$urlText <- renderText({ | |
| paste(sep = "", | |
| "protocol: ", session$clientData$url_protocol, "\n", | |
| "hostname: ", session$clientData$url_hostname, "\n", | |
| "pathname: ", session$clientData$url_pathname, "\n", | |
| "port: ", session$clientData$url_port, "\n", | |
| "search: ", session$clientData$url_search, "\n" | |
| ) | |
| }) | |
| # Parse the GET query string | |
| output$queryText <- renderText({ | |
| query <- parseQueryString(session$clientData$url_search) | |
| # Return a string with key-value pairs | |
| paste(names(query), query, sep = "=", collapse = ", ") | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| shinyUI(bootstrapPage( | |
| h3("URL components"), | |
| verbatimTextOutput("urlText"), | |
| h3("Parsed query string"), | |
| verbatimTextOutput("queryText") | |
| )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment