Skip to content

Instantly share code, notes, and snippets.

@dileephell
Created October 22, 2012 05:21
Show Gist options
  • Save dileephell/3929817 to your computer and use it in GitHub Desktop.
Save dileephell/3929817 to your computer and use it in GitHub Desktop.
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