Skip to content

Instantly share code, notes, and snippets.

@tj
Forked from anonymous/gist:2892237
Created June 7, 2012 23:06
Show Gist options
  • Save tj/2892258 to your computer and use it in GitHub Desktop.
Save tj/2892258 to your computer and use it in GitHub Desktop.
var express = require("express");
var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride()); // this uses req.body from bodyParser() so it should be below
app.use(express.static(__dirname + '/public'));
app.use(app.router);
});
app.post('/', function(req, res){
var user = req.body.username;
if (user == 'foo') {
res.sendfile(__dirname + '/public/index.html');
} else {
res.send('<p>Hello ' + user + '</p>');
}
});
app.listen(8080);
console.log("Server running");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment