Skip to content

Instantly share code, notes, and snippets.

@diem1
Last active August 5, 2016 12:55
Show Gist options
  • Save diem1/bb4ee23e751d5647b1d4 to your computer and use it in GitHub Desktop.
Save diem1/bb4ee23e751d5647b1d4 to your computer and use it in GitHub Desktop.
Ехо сервер на Node JS
var http = require('http');
var url = require('url');
var server = new http.Server(function(req, res){
console.log(req.method, req.url);
var urlParsed = url.parse(req.url, true);
console.log(urlParsed);
if(urlParsed.pathname = '/echo' && urlParsed.query.message){
res.end(urlParsed.query.message);
} else {
res.statusCode = 404;
res.end("not found");
}
});
server.listen(3333, '127.0.0.1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment