분류 전체보기 123

Express 설치 설정

Express 는 Node.js 위에서 돌아가는 Framework로 쉽게 node.js based web server 를 만들수 있도록 많은 기능들을 제공한다. 전세계 적으로 많은 회사 들에서 Express 를 사용하고 있다. command prompt 를 열고 "npm install express" 명령어를 치면, 아래와 같은 Warn 들이 나온다. 그럼 어떻게 해야 하는가? 1. 해당 Project Folder 로 이동한다. 2. "npm init" 을 치고, 질문들에 답을 하여 json file을 생성한다. 3. 그 후 "npm install express" 라고 입력하여, express 를 설치한다. 4. Express 의 version 체크와 update

web_fullstack 2020.07.29

node.js status code set

아래와 같이 코드를 짜고, 웹에서 http://localhost:3000/abc 와 같이 선언 되지 않은 page를 입력하면, page not found 가 회면에 나타난다. const http = require('http') const server = http.createServer((req,res)=>{ if(req.url==='/about') res.end('The about page') else if(req.url==='/contact') res.end('The contact page') else if(req.url==='/') res.end('The home page') else{ res.writeHead(404) res.end('page not found') } }) server.listen(..

web_fullstack 2020.07.29