◎ JavaScript/Node.js🫒

[Node.js] WEB Server 띄우기 [Node.js로 HTTP 서버 기동하기]

예르미(yermi) 2025. 4. 12. 21:16
728x90


- Node.js로 HTTP 서버 기동하기

const http = require('http');

// http 서버 생성
http
    .createServer((req, res) => {
        // 클라이언트에 반환할 내용을 쓴다.
        res.write('hello world\n');
        // 클라이언트에 내용을 송신
        res.end();
    })
    .listen(3000); // 포트번호 3000

Node.js, hello world!


728x90