Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2012 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2892237 to your computer and use it in GitHub Desktop.
Save anonymous/2892237 to your computer and use it in GitHub Desktop.
var express = require("express");
var app =express.createServer();
// ------
app.configure(function(){
app.use(express.methodOverride());
app.use(express.static(__dirname + '/public'));
app.use(express.bodyParser());
app.use(app.router);
});
app.post('/',function(req,res){
if (req.body.username == "asd"){
res.writeHead(200,{ 'Content-type':'text/html'});
res.sendfile("index.html");
console.log("correct");
res.end();
}
else{
console.log("entered:" + req.body.username);
res.writeHead(200,{ 'Content-type':'text/html'});
res.write("<h>Hello "+req.body.username +"</h>");
res.end();
};
});
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