Пожалста. Но для упражнения-то? Тырц:
var http = require('http')
, url = require('url');
var html = '\
<!doctype html> \
<html> \
<head> \
<meta charset="utf-8"> \
</head> \
<body> \
<form name="form" action="/form"> \
<input type="text" name="user"><br> \
<input type="password" name="pass"><br> \
<button type="submit">Go</button> \
</form> \
</body> \
</html>'
http.createServer(function(req, res) {
var urlParse = url.parse(req.url, true);
if(req.url == '/') {
res.end(html);
} else if(urlParse.pathname == '/form') {
console.log(urlParse.query);
res.setHeader('content-type', 'text/html;charset=utf-8');
res.end('Сенк-ю');
}
}).listen(3000, () => console.log('Running on PORT: 3000'));