-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (26 loc) · 1 KB
/
Copy pathserver.js
File metadata and controls
31 lines (26 loc) · 1 KB
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
const express = require('express');
const app = express();
const port = 3000; // You can change the port as needed
// Middleware to serve static files (HTML, CSS, images, etc.) from the "public" directory
app.use(express.static('public'));
app.use(express.json());
// Example timetable data
let timetableData = {
"Monday": ["Math", "Chemistry", "Physics", "English", "History"],
"Tuesday": ["Physics", "Math", "Chemistry", "History", "English"],
"Wednesday": ["History", "English", "Math", "Physics", "Chemistry"],
"Thursday": ["", "", "", "", ""], // You can initialize this with empty values
"Friday": ["Chemistry", "History", "English", "Math", "Physics"]
};
// Endpoint to get timetable data
app.get('/timetable', (req, res) => {
res.json(timetableData);
});
// Endpoint to update timetable data
app.put('/timetable', (req, res) => {
timetableData = req.body;
res.json({ message: 'Timetable updated successfully' });
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});