Last active
August 5, 2016 12:55
-
-
Save diem1/bb4ee23e751d5647b1d4 to your computer and use it in GitHub Desktop.
Ехо сервер на Node JS
This file contains hidden or 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'); | |
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