Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created June 4, 2012 18:04
Show Gist options
  • Save ovaillancourt/2869908 to your computer and use it in GitHub Desktop.
Save ovaillancourt/2869908 to your computer and use it in GitHub Desktop.
middlleware that catches stuffs the router didn't serve.
var express = require('express');
//Create the express app;
var app = express.createServer();
app.use(app.router);
//You place this middleware right after your router so paths that the
//router can't match will go through it and finally end here.
app.use(function(req, res, next){
//There you can render a view or put a 404 error page, anything you want.
return res.send('Hello this is my static page');
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment