Skip to content

Instantly share code, notes, and snippets.

@h09shais
Created November 10, 2018 06:28
Show Gist options
  • Save h09shais/ab05bbebd8bd2188fa97e4ada1206839 to your computer and use it in GitHub Desktop.
Save h09shais/ab05bbebd8bd2188fa97e4ada1206839 to your computer and use it in GitHub Desktop.
Display PDF by using node express
/*
$ npm init
$ npm install express
$ touch app.js
$ node app.js
*/
var express = require("express"),
fs = require("fs"),
app = express();
app.get("/", function(req, res) {
fs.readFile("helloworld.pdf", function(err, data) {
res.contentType("application/pdf");
res.send(data);
});
});
app.listen(3000, function() {
console.log("Listening port: 3000!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment