-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (23 loc) · 921 Bytes
/
Copy pathserver.js
File metadata and controls
33 lines (23 loc) · 921 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
27
28
29
30
31
32
33
const express = require('express');
const path = require('path');
const app = express();
const port = 3000;
// Serve static files from the "public" directory
app.use(express.static(path.join(__dirname, 'public')));
// Example route for serving the index.html
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'hello.html')); // Make sure it's in the "public" folder
});
app.get('/login', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'login.html')); // Serve the about.html page
});
app.get('/about', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'about.html')); // Serve the about.html page
});
app.get('/contacts', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'contacts.html')); // Serve the contacts.html page
});
// Start the server
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});