Express 바닥부터 구현해보기 # Hello world 예제

이건우·2021년 12월 14일
0

Node.js

목록 보기
4/4
  1. app.js 이름의 파일에 다음과 같은 코드를 추가한다.
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

2.node app.js 명령어를 터미널에 입력한다.

3.localhost:3000을 클릭

app.get('/hello', (req, res) => {
  res.send('Hello World!')
})

만약 위와 같이 getendpoint/hello 를 입력하지 않는이상 아래와 같이 페이지가 뜬다.

profile
내가 느낌만알고 한줄도 설명할줄 모른다면 '모르는 것'이다.

0개의 댓글