-
-
Notifications
You must be signed in to change notification settings - Fork 401
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (16 loc) · 575 Bytes
/
app.js
File metadata and controls
21 lines (16 loc) · 575 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const express = require('express');
const path = require('path');
const indexRouter = require('./routes/index');
const app = express();
const PORT = 3000;
// Serve static files from the "public" directory
app.use(express.static(path.join(__dirname, 'public')));
// Use the router for handling routes
app.use('/', indexRouter);
// Catch-all route for handling 404 errors
app.use((req, res, next) => {
res.status(404).sendFile(path.join(__dirname, 'views', '404.html'));
});
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});