I'm building an R/Shiny app which is supposed to execute some code when called via HTTP GET, much similar to the first answer to this question. Now, the app works just fine when I view it through the web browser, but what I want is really to be able to call the app remotely outside of the web browser, e.g. via a HTTP GET call from cURL or server-side javascript, and make it execute code using URL parameters sent to it as input.
If I visit the following URL in my web browser (assuming that the Shiny app is running on localhost), everything works just fine:
http://127.0.0.1:8000/?param1=val1¶m2=val2
But if I instead call the same URL using cURL, nothing happens (except the HTML for the Shiny App is returned):
curl -X GET http://127.0.0.1:8000/\?param1=val1\¶m2=val2
My app was basically built as an expansion upon the example app in the first answer to the question linked above (by user @jdharrison), only it also executes some code that is exclusively server-side (i.e. not visible to the user and not returned on the front end), so that should hopefully suffice as a code example:
library(shiny)
runApp(list(
ui = bootstrapPage(
textOutput('text')
),
server = function(input, output, session) {
output$text <- renderText({
query <- parseQueryString(session$clientData$url_search)
paste(names(query), query, sep = "=", collapse=", ")
})
}
), port = 5678, launch.browser = FALSE)
Many thanks in advance!