-
-
Save tj/2892258 to your computer and use it in GitHub Desktop.
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"); | |
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