Skip to content

Instantly share code, notes, and snippets.

@mndrake
Last active September 1, 2016 02:14
Show Gist options
  • Save mndrake/44dc767b67701bc990079bf096c47e4e to your computer and use it in GitHub Desktop.
Save mndrake/44dc767b67701bc990079bf096c47e4e to your computer and use it in GitHub Desktop.
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 = ", ")
})
})
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