Created
November 16, 2012 05:53
-
-
Save dileephell/4084576 to your computer and use it in GitHub Desktop.
dileep form
This file contains 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 http = require('http'); | |
http.createServer(function (req, res) { | |
// set up some routes | |
switch(req.url) { | |
case '/': | |
// show the user a simple form | |
console.log("[200] " + req.method + " to " + req.url); | |
res.writeHead(200, "OK", {'Content-Type': 'text/html'}); | |
res.write('<html><head><link rel="stylesheet" type="text/css" href="style.css"><title>Hello Noder!</title></head><body>'); | |
res.write('<h1>Welcome to Trendstiger</h1>'); | |
res.write('<h2>Welcome to Trendstiger</h2>'); | |
res.write('<h2 style="color: red;">Welcome to Trendstiger</h2>'); | |
res.write('<form enctype="application/x-www-form-urlencoded" action="/formhandler" method="post">'); | |
res.write('Name: <input type="text" name="username" value="" /><br />'); | |
res.write('Age: <input type="text" name="userage" value="" /><br />'); | |
res.write('Company: <input type="text" name="usercompany" value="" /><br />'); | |
res.write('Profile: <input type="text" name="userprofile" value="" /><br />'); | |
res.write('Address: <input type="text" name="useraddress" value="" /><br />'); | |
res.write('<input type="submit" />'); | |
res.write('</form></body></html>'); | |
res.end(); | |
case '/formhandler': | |
if (req.method == 'POST') { | |
console.log("[200] " + req.method + " to " + req.url); | |
req.on('data', function(chunk) { | |
console.log("Received body data:"); | |
console.log(chunk.toString()); | |
}); | |
} | |
} | |
}).listen(9029); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment