4

I have a functional shinyapp, and I would like for it to launch when called through an HTTP request, but with the POST method.

Here is a simple example:

My shinyapp is accessible through the browser at: http://127.0.0.1:5527.

To try out launching with POST, I have a simple HTML file consisting of a simple form, and I would like that a click on the submit button redirects me to my shinyapp.
Here is the html code:

<body>
    <form method="post" action="http://127.0.0.1:5527/" enctype="multipart/form-data">

    <input type="text" name="name" id="nameID"/>

    <input type="submit" value="Submit" />

    <a href="http://127.0.0.1:5527/">To Shiny (w/ GET)</a>
</body>

But when I click on the 'Submit' button, only a huge "Not found" is displayed, whereas when I click on the address bar and press Enter (or click on the usual <a>To Shiny</a> link), it works well and the shinyapp launches.

My ultimate goal is to send a JSON inside my POST request, that the shiny app will use as input. But I am frustrated to not be able to launch the app with such a simple request (that would then allow me to dig in the session object to retrieve the JSON object, or at least try!)

I have tried the solution explained here: Accept HTTP Request in R shiny application but the answer does not cover this case.
I have also read https://github.com/rstudio/shiny/issues/1718, where it is said that such API functionality were expected to be released a year ago, but it has not.
My last resort has been to browse the shiny github branch where the API was developed (https://github.com/rstudio/shiny/compare/feature/api) and even pull it, but since it is not documented I have no idea where to start!!

Any idea on how to allow an HTTP/POST request to launch my shinyapp? Furthermore, if anyone knows how to access a JSON in the request, that would be of great help!

Thanks!

jav
  • 49
  • 4

0 Answers0