Last active
August 23, 2018 20:41
-
-
Save Anna-Myzukina/deaf155705e4e62cb251ebcc5ba0552f to your computer and use it in GitHub Desktop.
node => my education
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
console.log("a: "+a+", b: "+b+", c: "+c);//a: 1, b: 5, c: 6 |
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
//Создадим первый сервер который выведет в браузере Hello World | |
//работающий сервер его можно проверить запустив в командной строке >node server.js и затем открыть в браузере http://localhost:8888/ выведет Hello World | |
//Первая строчка подключает http-модуль, который поставляется вместе с Node.js и делает его доступным через переменную http | |
var http = require("http"); | |
//Далее, мы вызываем одну из функций http-модуля createServer Эта функция возвращает объект, имеющий метод listen, принимающий числовое значение порта нашего HTTP-сервера, который необходимо прослушивать. | |
http.createServer(function(request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
response.write("Hello World"); | |
response.end(); | |
}).listen(8888);//код, который запускает наш сервер, прослушивающий порт 8888 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment