-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (23 loc) · 755 Bytes
/
index.js
File metadata and controls
26 lines (23 loc) · 755 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
const http = require('http');
const { logsController } = require('./apis');
const PORT = 80;
http.createServer(async (req, res) => {
const requestUrl = req.url.split('?');
const controllerUrl = requestUrl[0].split('/');
// First Level router
switch(controllerUrl[1]) {
case 'logs':
await logsController(req, res);
break;
case 'test':
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('test');
res.end();
break;
default:
res.writeHead(404, {'Content-Type': 'text/html'});
res.write('Requested url not found.');
res.end();
}
}).listen(PORT);
console.log(`server is running on port ${PORT}`);