-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (20 loc) · 766 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (20 loc) · 766 Bytes
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
const express = require('express');
const path = require('path');
require('dotenv').config();
const jdRoutes = require('./routes/jdRoutes');
const app = express();
const PORT = process.env.PORT || 3000;
// Cấu hình view engine EJS và thư mục views
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// Middleware để parse dữ liệu POST
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// Cấu hình thư mục chứa file tĩnh (CSS, JS, hình ảnh, ...)
app.use(express.static(path.join(__dirname, 'public')));
// Sử dụng routes của JD
app.use('/', jdRoutes);
// Khởi chạy server
app.listen(PORT, () => {
console.log(`Server đang chạy trên http://localhost:${PORT}`);
});