기존(310)/🏀Node
[Node.js] html 파일 보내기 path,__dirname
조각남자
2022. 6. 8. 21:09
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
const path = require('path'); // 파일 폴더 가져오기
const express = require('express'); // 서버 생성
const router = express.Router(); // 서버 라우터 생성
router.get('/',(req,res,next)=>{
console.log('여기로 넘어와랑');
res.sendFile(path.join(__dirname,'../','views','shop.html')); // 절대경로를 고정시켜주는것 path.join(__dirname), _dirname=router 폴더의미
})
module.exports= router;
res.sendFile(path.join(__dirname,'../','views','shop.html')); // 절대경로를 고정시켜주는것 path.join(__dirname), _dirname=router 폴더의미
path.join(__dirname == 현재 rotues폴더
../ == 상위폴더로 들어가서
views == views 에 있는
shop.html == shop.html 에 ㅂㅗ낸다
const path = require('path'); // 파일 경로 임포트
|
cs |
