const http = require('http')
const server = http.createServer((req, res) => {
res.statusCode = 200
res.end('Hello!')
})
const PORT = 3000
server.listen(PORT, () => {
console.log('The server is lisening at port', PORT)
})
http로 연결하고, 3000번 포트를 사용한다.
콜백함수를 사용하여, 200번 코드가 나오면, Hello!라는 문구가 뜬다.
'JavaScript > Node.js' 카테고리의 다른 글
Express 설치 (0) | 2023.08.13 |
---|---|
TypeScript 설치 (0) | 2023.08.13 |
ESLint 설치 (0) | 2023.08.12 |
prettier 설치 (0) | 2023.08.12 |
package.json (0) | 2023.08.12 |