Created
September 19, 2012 21:12
-
-
Save jasonmorganson/3752290 to your computer and use it in GitHub Desktop.
Simple static file server using Express
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' ), | |
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