Page 153 - Nodejs 교과서 개정2판
P. 153
ҙೠ ࠁٜਸ res ёח ী ҙೠ ࠁٜਸ Ҋ णפ
ই ٘ܳ प೯೧ب ইޖ ੌب ੌযա ঋणפ ਃী ೠ ب ֍য ঋওҊ ࢲߡ৬ োѾೞب
ঋওӝ ٸޙੑפ ઁীࢲ ਸ ࠁղח ࠗ࠙җ ࢲߡী োѾೞח ࠗ࠙ਸ ୶о೧ࠁѷणפ
server1.js
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.write('<h1>Hello Node!</h1>');
res.end('<p>Hello Server!</p>');
})
.listen(8080, () => { // 서버 연결
console.log('8080번 포트에서 서버 대기 중입니다!');
});
٘ܳ ࢸݺೞӝী খࢲ ݢ ࢲߡܳ प೯೧ࠇद
콘솔
$ node server1
8080번 포트에서 서버 대기 중입니다!
ࣛী ਤ৬ э ޙ ա৳ݶ ࢿҕੑפ ઁ ਢ ࠳ۄܳ ৌয IUUQ MPDBMIPTU ژח IUUQ
ী ࣘפ
/PUF MPDBMIPTU৬ ನۆ
MPDBMIPTUח അ ஹೊఠ ղࠗ ࣗܳ оܻఈפ ৻ࠗীࢲח Ӕೡ ࣻ হҊ न ஹೊఠীࢲ݅ Ӕೡ ࣻ ਵ۽ ࢲ
ߡ ѐߊ द పझਊਵ۽ ݆ ࢎਊؾפ MPDBMIPTU न ਸ ࣗ۽ ࢎਊ೧ب эणפ ۞ೠ ं ࣗܳ *1 *OU
FSOFU 1SPUPDPM ۄҊ ࠗܵפ
ನח ࢲߡ ղীࢲ ۽ࣁझܳ ҳ࠙ೞח ߣഐੑפ ࢲߡח )551 ਃਸ ӝೞח Ѫ ৻ীب নೠ সਸ פ ؘఠ
߬झ৬ب ాन೧ঠ ೞҊ '51 ਃਸ ܻೞӝب פ ٮۄࢲ ࢲߡח ۽ࣁझী ನܳ ܰѱ ೡೞৈ ٜযয়ח ਃ
ਸ ҳ࠙פ ਬݺೠ ನ ߣഐ۽ח '51 )551 )5514 .:42- णפ ನ ߣഐח *1 ࣗ
ٍী ۿ җ ೣԋ ࠢৈ ࢎਊפ