Created
November 10, 2018 06:28
-
-
Save h09shais/ab05bbebd8bd2188fa97e4ada1206839 to your computer and use it in GitHub Desktop.
Display PDF by using node express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$ 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