-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (24 loc) · 777 Bytes
/
server.js
File metadata and controls
27 lines (24 loc) · 777 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
const http = require('http');
const fs = require('fs');
const path = require('path');
const PORT = 3322;
const HTML_FILE = path.join(__dirname, 'device-testing-checklist.html');
const server = http.createServer((req, res) => {
if (req.url === '/' || req.url === '/index.html') {
fs.readFile(HTML_FILE, (err, data) => {
if (err) {
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Error loading checklist');
return;
}
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(data);
});
} else {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Not found');
}
});
server.listen(PORT, () => {
console.log(`Device Testing Checklist running at http://localhost:${PORT}`);
});