본문 바로가기

JS/node.js

[nodeJS] 파일 로드

728x90

get요청 시 html 파일 전송

res. sendFile(파일명)

// html 파일 전송
app.get('/', function(req, res) { // '/' : 홈
    res.sendFile(__dirname + '/index.html')
})
const express = require('express'); // 설치한 라이브러리를 첨부
const app = express(); // 첨부한 라이브러리로 객체 생성

// html 파일 전송
app.get('/', function(req, res) { // '/' : 홈
    res.sendFile(__dirname + '/index.html')
})

 

 

 

728x90

'JS > node.js' 카테고리의 다른 글

[nodeJS] BootStrap  (1) 2022.06.28
[nodeJS] nodemon 라이브러리  (0) 2022.06.28
[nodeJS] 서버 생성  (0) 2022.06.28
[nodeJS] Express 라이브러리  (0) 2022.06.28
[nodeJS] nodejs, vs코드 설치  (0) 2022.06.28