Created
July 8, 2017 20:30
-
-
Save saifsmailbox98/c5b6d327ef1cdf927671991d8115a1d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var express = require("express"); | |
| var path = require("path"); | |
| var app = express(); | |
| var filePath = path.join(__dirname, "celine.jpg"); | |
| app.use(function(req, res, next){ | |
| res.sendFile(filePath, function(err){ | |
| if(err){ | |
| next(new Error("Error sending the file!")); | |
| } | |
| }); | |
| }); | |
| app.use(function(err, req, res, next){ | |
| console.error(err); | |
| next(err); | |
| }); | |
| app.use(function(err, req, res, next){ | |
| res.status(500); | |
| res.send("Internal server error."); | |
| }); | |
| app.listen(8080, function(){ | |
| console.log("App started on port 8080"); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment