-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 798 Bytes
/
server.js
File metadata and controls
28 lines (22 loc) · 798 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
const express = require('express');
const path = require('path');
const session = require('express-session');
const app = express();
const port = 3000;
app.use(express.json()); // Parse JSON bodies
// Middleware to serve static files
app.use(express.static(path.join(__dirname, 'public')));
// Session management
app.use(session({ secret: 'your_secret_key', resave: true, saveUninitialized: true }));
// Serve index.html on root
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
// Handle the profile page after authentication
app.get('/profile', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'profile.html'));
});
// Start the server
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});