Skip to content

Instantly share code, notes, and snippets.

@nickfox
Created October 13, 2011 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickfox/1283332 to your computer and use it in GitHub Desktop.
Save nickfox/1283332 to your computer and use it in GitHub Desktop.
var express = require('express');
var fs = require('fs');
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// Routes
app.get('/', function(req, res){
fs.readFile(__dirname + '/public/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html ' + err);
}
res.writeHead(200);
res.end(data);
});
});
app.listen(8137);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment