Skip to content

Instantly share code, notes, and snippets.

@JohnCoene
Created October 6, 2020 12:57
Show Gist options
  • Save JohnCoene/926d24536d3051a144e42047e5e306a5 to your computer and use it in GitHub Desktop.
Save JohnCoene/926d24536d3051a144e42047e5e306a5 to your computer and use it in GitHub Desktop.
Intro to HTTP requests with shiny
library(shiny)
ui <- fluidPage(
uiOutput("intro")
)
server <- function(input, output, session){
# serve the response
path <- session$registerDataObj(
name = "hello",
data = "<h1>Hello there!</h1>",
function(data, req) {
shiny:::httpResponse(
content = data
)
}
)
# print path
output$intro <- renderUI({
# print so we can see the path clearly
print(path)
# print it big so we can see it
h1(
tags$a(path, href = path)
)
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment