> For the complete documentation index, see [llms.txt](https://yong2401.gitbook.io/til-by-ellie/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yong2401.gitbook.io/til-by-ellie/node.js/node.js_httpserver.md).

# Node.js 로 http server 구축

* VsCode - Node.js 폴더 안에 Node\_httpServer.js 파일 생성

  ```jsx
  // Node.js로 http server 구축
  const http = require("http");
  http
    .createServer((req, res) => {
      res.write("Hello Node Server");
      res.end();
    })
    .listen(8080);

    console.log("http server를 실행합니다.");
  ```
* node terminal에서 **node** Node\_httpServer.js 실행 ![node.js\_console2](/files/-MaQx9_k8UGDUHbeQaTD)
* <http://localhost:8080>으로 접속해서 http server 생성 확인 ![httpServer](/files/-MaQx9_l6wXCtb0YNDLk)
