Page 213 - Nodejs 교과서 개정2판
P. 213
§ Ӓܿ MPDBMIPTU ࣘ ചݶ
ױࣽೠ ޙৌ न )5.-۽ ೞҊ रݶ res.sendFile ݫࢲ٘ܳ ࢎਊೞݶ ؾפ ױ ੌ ҃۽ܳ QBU
I ݽٕਸ ࢎਊ೧ࢲ ೧ঠ פ
index.html
<html>
<head>
<meta charset="UTF-8" />
<title>익스프레스 서버</title>
</head>
<body>
<h1>익스프레스</h1>
<p>배워봅시다.</p>
</body>
</html>
app.js
const express = require('express');
const path = require('path');
const app = express();
app.set('port', process.env.PORT || 3000);
app.get('/', (req, res) => {
// res.send('Hello, Express');
res.sendFile(path.join(__dirname, '/index.html'));
});
app.listen(app.get('port'), () => {
console.log(app.get('port'), '번 포트에서 대기 중');
});