Static file server in R
June 24, 2024
Plumber, ambiorix, and opencpu are the keys to putting R into production.
Sometimes all an API needs to do is statically serve files. Making a static file server with R is insanely easy.
For this example, I have a folder called /public which I want to serve
files from at the API path /static.
To do this we create a plumber API using the pr_static() function or
#* @assets if using the other plumber declaration format.
Making the file server
|>
|>
calling the file server
We can call this api using a GET request:
iris_csv <- |>
|>
readr::
Alternative plumber format
#* @assets ./public /static