Reputation: 156
I'd like to make a shiny app that pulls a value from the url, but doesn't need to have an input element to work. E.g. I know I could do:
library(shiny)
shinyApp(
ui = fluidPage(
textInput("text", "Text", ""),
textOutput("outtext")
),
server = function(input, output, session) {
output$outtext <- renderText(input$text)
observe({
query <- parseQueryString(session$clientData$url_search)
if (!is.null(query[['text']])) {
updateTextInput(session, "text", value = query[['text']])
}
})
}
)
and that would pull from the app's url after /?text=abc, but what I'd really like is to be able to print the value from the url without having a textInput box. Is this possible?
Upvotes: 0
Views: 174
Reputation: 11878
Yes; render the query parameter directly:
library(shiny)
shinyApp(
ui = fluidPage(
textOutput("outtext")
),
server = function(input, output, session) {
output$outtext <- renderText(getQueryString()[["text"]])
}
)
Upvotes: 2