Skip to content

Instantly share code, notes, and snippets.

@louismullie
Last active July 24, 2020 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louismullie/c801e483e5d0b9b0cb57c33b8dc97fb9 to your computer and use it in GitHub Desktop.
Save louismullie/c801e483e5d0b9b0cb57c33b8dc97fb9 to your computer and use it in GitHub Desktop.
Example D3-Node-R stack
const R = require('r-script')
const express = require('express')
const app = module.exports = express()
app.use(app.router)
app.get("/dashboard", function (req, res, next) {
res.send("Some HTML with D3.js code")
})
app.post("/api/meta", function(req, res, next) {
const result = R("./scripts/meta.R").data().callSync()
res.send({ status: 200, response: result })
})
// Start listening on port 3000 on localhost
app.listen(3000, "localhost")
console.log("[ OK ] Listening on port 3000")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment