Инструменты пользователя

Инструменты сайта


nodejs:osnovy:module_http:createserver

createServer

const http = require('http');
 
/**
 * calback функция - обработчик запросов ,
 * request - запрос
 * response - ответ
 */
const server = http.createServer(function(request, response){
    console.log(request.url);//вернет в консоль url - http://127.0.0.1:3000/adda
    //в консоле - /adda
 
});
 
/**
 * Установить прослушку на 3000 порт
 */
server.listen(3000, function(){
 
    console.log('server start on port 3000');
});
nodejs/osnovy/module_http/createserver.txt · Последние изменения: 2023/01/12 12:18 (внешнее изменение)