728x90
반응형
1. Visual Studio Code를 이용해서 간단한 코드 작성
작업할 폴더 생성 -> hello.js 파일 생성
// Load HTTP module
var http = require("http");
// Create HTTP server and listen on port 8000 for requests
http.createServer(function(request, response) {
// Set the response HTTP header with HTTP status and Content type
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body "Hello World"
response.end('Hello World\n');
}).listen(8000);
// Print URL for accessing server
console.log('Server running at http://127.0.0.1:8000/');
2. 소스 실행
cmd -> 작업할 폴더 경로 입력 -> node hello.js(파일명) 입력
3. 링크로 접속 http://127.0.0.1:8000/
728x90
반응형
'Programming > Node.js' 카테고리의 다른 글
[Node.js_생활코딩] 동적인 웹페이지 만들기_파일 읽어서 본문 변경 (0) | 2021.02.16 |
---|---|
[Node.js_생활코딩] 동적인 web page 만들기 (0) | 2021.02.16 |
[Node.js] 커스텀 모듈 작성 (0) | 2021.02.16 |
[Node.js] Express framework 설치 및 실행, 800A138F 오류 (0) | 2021.02.16 |
[Node.js]Node.js 설치 및 확인 (0) | 2021.02.16 |