[Node.js] http 클래스를 활용한 기본 서버 구성
.Node.js http 클래스를 활용한 기본 서버 구성 123456789var http = require("http"); http.createServer(function (req, res) { var body = "hello Server"; res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.end("This is My Server~~~!"+body+"")}).listen(3000); console.log('server is Started'); cs line 1) http 모듈을 require()로 불러온다.line 4) body에 넣을 textline 5) response의 Header를 설정line 7) 3000번 port로 서버 대기
Web
2020. 6. 22. 11:31