-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (53 loc) · 1.46 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* eslint-disable no-undef */
import express from 'express';
import path from 'path';
const app = express();
const BASE_DIR = path.join(__dirname, 'src');
const HTML_DIR = path.join(BASE_DIR, 'html');
const port = 3033;
//console.log({ BASE_DIR, HTML_DIR });
const router = express.Router();
app.use((_, res, next) => {
let now = new Date();
console.log('Time: ', now.toUTCString());
next();
});
router.get('/', (_, res) => {
res.sendFile(`${HTML_DIR}/index.html`);
});
router.get('/index', (_, res) => {
res.sendFile(`${HTML_DIR}/index.html`);
});
router.get('/typing', (_, res) => {
console.log('typing....');
res.sendFile(`${HTML_DIR}/typing.html`);
});
router.get('/reader', (_, res) => {
res.sendFile(`${HTML_DIR}/reader.html`);
});
router.get('/panel', (_, res) => {
res.sendFile(`${HTML_DIR}/panel.html`);
});
router.get('/hindi', (_, res) => {
res.sendFile(`${HTML_DIR}/hindi.html`);
});
router.get('/tree', (_, res) => {
res.sendFile(`${HTML_DIR}/tree.html`);
});
router.get('/record', (_, res) => {
console.log('Accessing the record section…');
res.sendFile(`${HTML_DIR}/record.html`);
});
router.get('/color', (_, res) => {
res.sendFile(`${HTML_DIR}/color.html`);
});
// error handling middleware
app.use((err, req, res, _) => {
console.error(err.stack);
res.status(500).send('Something broke!');
});
app.use('/', express.static(BASE_DIR));
app.use('/', router);
app.listen(port, () => {
console.log(' listening port ' + port);
});