-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskpage.js
47 lines (37 loc) · 1.12 KB
/
taskpage.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const express = require('express');
const mysql = require('mysql2');
const app = express();
const port = 3000;
app.use(express.static('public'));
const db = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "login_details"
});
app.get('/', (req, res) => {
res.sendFile(__dirname + '/../../AAC_LMS/mentor/html/createTask.html');
});
// Endpoint to fetch data from the 'tasks' table
app.get('/tasks', (req, res) => {
db.query('SELECT * FROM tasks', (err, results) => {
if (err) {
res.status(500).json({ error: 'Internal Server Error' });
} else {
res.status(200).json(results);
}
});
});
// Endpoint to fetch data from the 'links' table
app.get('/links', (req, res) => {
db.query('SELECT * FROM links', (err, results) => {
if (err) {
res.status(500).json({ error: 'Internal Server Error' });
} else {
res.status(200).json(results);
}
});
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});