Skip to content

Instantly share code, notes, and snippets.

@saifsmailbox98
Created July 8, 2017 20:30
Show Gist options
  • Save saifsmailbox98/c5b6d327ef1cdf927671991d8115a1d3 to your computer and use it in GitHub Desktop.
Save saifsmailbox98/c5b6d327ef1cdf927671991d8115a1d3 to your computer and use it in GitHub Desktop.
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