APP
[Nodejs] 서버 코딩 및 서버 실행
챈챈_
2019. 12. 6. 15:12
웹 앱을 만들려면 먼저 서버가 준비되어 있어야 합니다.
간단한 코드로 서버를 실행시켜보겠습니다.
개발 환경 : Visual Studio Code
1
2
3
4
5
6
7
8
9
10
11
|
var express = require('express'); //모듈 추출
var app = express(); //서버생성 : app
app.use(function(request, response) {
response.writeHead(200, { 'Content-Type': 'text/html'});
response.end('<h1>Hello Express!</h1>');
});
app.listen(1, function() {
console.log("Server Running at http://127.0.0.1:1");
});
|
이렇게 하고 실행을 시킵니다.
[Visual Studio Code]
[Terminal]-[New Terminal]
[일반 터미널]
[cd Directory(js파일 저장 폴더) - node 이름.js 입력]
결과는?