Created
November 3, 2025 09:38
-
-
Save alekrutkowski/1ddadde02701b3908935f35fba7cd30e to your computer and use it in GitHub Desktop.
R/Shiny app as a simple GET request handler
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
| # Save it as /srv/shiny-server/your_app_name/app.R | |
| library(shiny) | |
| ui <- function(request) { | |
| query <- parseQueryString(request$QUERY_STRING) | |
| txt <- query$txt | |
| a <- as.numeric(query$a) | |
| b <- as.numeric(query$b) | |
| if (is.null(txt) || length(a)==0 || length(b)==0) | |
| httpResponse( | |
| status = 400, | |
| content_type = "text/plain; charset=UTF-8", | |
| content = 'One of the GET parameters (txt or a or b -- each case sensitive!) not provided!' | |
| ) else | |
| httpResponse( | |
| status = 200, | |
| content_type = "text/plain; charset=UTF-8", | |
| content = paste(toupper(txt), | |
| a + b, | |
| sep='\n') | |
| ) | |
| } | |
| server <- function(input, output, session) {} | |
| shinyApp(ui = ui, server = server) | |
| # test: | |
| # https://localhost:8787/your_app_name/?txt=hello%20world&a=12&b=13 | |
| # or | |
| # https://your.shinyserver.domain/your_app_name/?txt=hello%20world&a=12&b=13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment