Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2012 23:01

Revisions

  1. @invalid-email-address Anonymous created this gist Jun 7, 2012.
    42 changes: 42 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@

    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");