WARNING: This is a proof of concept only. It is not ready for production.
A simple HTTP server written in R that serves up parameterized RMarkdown files. The key difference compared to services like http://rpubs.com is the RMarkdown files are re-rendered with each unique set of parameter-values passed in the query string.
Any Rmd file in ./public
can be served. Parameters are expressed in standard RMarkdown metadata. Read more about RMarkdown params here: https://bookdown.org/yihui/rmarkdown/.
The server translates any query-params passed in the URL to the RMarkdown file via the rmarkdown::render() params argument.
Make sure you have R installed. RStudio is not strictly required, but we'll assume you are using it:
-
R: https://www.r-project.org/ - v3.6.2
Git-clone this repository and then open rmarkdown-server.RProj. Install the required packages by executing this in the RSudio console:
renv::restore()
start or restart server:
source('./server.R')
stop server:
.GlobalEnv$runningServer$stopServer()
Get a rendered rmarkdown file:
The .Rmd extension is optional:
Pass params in the query string:
Precede the path with /params/
to get a JSON object directly derived from the params
property in the Rmarkdown file's metadata:
leaflet.Rmd metadata:
title: Leaflet Demo
output: html_document
params:
tiles:
label: "Tiles"
value: "normal"
input: "select"
choices:
- "normal"
- "monochrome"
/params/leaflet.Rmd output:
{
"tiles": {
"label": [
"Tiles"
],
"value": [
"normal"
],
"input": [
"select"
],
"choices": [
"normal",
"monochrome"
]
}
}
The .Rmd extension is optional:
Currently a url could have "/../" in the path and give access outside public/
.