> 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](https://175612507-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaQwJWfxFFpOmmWNN4g%2Fsync%2F82679ec655aa59e6b1584892c2bddea25b4e7256.png?generation=1621819178405854\&alt=media)
* <http://localhost:8080>으로 접속해서 http server 생성 확인 ![httpServer](https://175612507-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaQwJWfxFFpOmmWNN4g%2Fsync%2F6d4a7fa29094fa3453441918f0aa92cefdde14f5.png?generation=1621819178491040\&alt=media)
