Skip to content

Instantly share code, notes, and snippets.

@jasonmorganson
Created September 19, 2012 21:12
Show Gist options
  • Save jasonmorganson/3752290 to your computer and use it in GitHub Desktop.
Save jasonmorganson/3752290 to your computer and use it in GitHub Desktop.
Simple static file server using Express
var express = require( 'express' ),
consolidate = require( 'consolidate' ),
app = express();
var port = process.env.PORT || 80;
// Assign the jade engine to .html files
app.engine( 'html', consolidate.jade );
// Set .html as the default extension
app.set( 'view engine', 'html' );
app.set( 'views', __dirname + '/views' );
app.use( express.static( __dirname ) );
app.use( express.static( __dirname + '/js' ) );
app.use( express.static( __dirname + '/css' ) );
app.configure( 'development', function() {
app.use( express.errorHandler( { dumpExceptions: true, showStack: true } ) );
});
app.configure( 'production', function() {
app.use( express.errorHandler() );
});
app.use( app.router );
app.listen( port, function() {
console.log( "Listening on " + port );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment