Created
October 22, 2012 05:21
-
-
Save dileephell/3929817 to your computer and use it in GitHub Desktop.
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 sys = require('sys'), | |
http = require('http'); | |
http.createServer(function (req, res) { | |
switch (req.url) { | |
case '/': | |
res.writeHead(200, {'Content-type': 'text/html'}); | |
res.end( | |
'<form action="/myaction" method="post" enctype="multipart/form-data">'+ | |
'<input type="text" name="field1">' + | |
'<input type="text" name="field2">' + | |
'<input type="submit" value="Submit">' + | |
'</form>' | |
); | |
break; | |
case '/myaction': | |
res.writeHead(200, {'Content-type': 'text/html'}); | |
sys.puts('Hello'); | |
/* | |
if (req.method == 'POST') { | |
req.on('data', function(chunk){ | |
res.writeHead(200, chunk.toString()); | |
}); | |
} | |
*/ | |
break; | |
} | |
}).listen(8080); | |
sys.puts('Server running at http://127.0.0.1:8080/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment