-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (31 loc) · 1021 Bytes
/
server.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
/* zeer simpele server die op /htmlreport het htmlrapport
* van de laatste run laat zien */
const fs = require("fs-extra");
const http = require("http");
const host = 'localhost';
const port = 7000;
const data = require ('./cypress.config.js');
const requestListener = function (req, res) {
let html = '<HTML><body><h1>onbekend</h1></body></HTML>';
switch(req.url) {
case '/htmlreport':
html = fs.readFileSync( data['htmlreportsFolder'] + '/index.html');
break;
case '/test':
html ='<HTML><p>Dit is een test</p></HTML>';
break;
case '/formulier':
html = fs.readFileSync( `${__dirname}/formulier.html`);
break;
default:
html = '<HTML><body><h1>niet bekend</h1></body></HTML>';
};
res.setHeader("Content-Type", "text/html");
res.writeHead(200);
res.end(html);
}
console.log ('screenshots in ' + data['screenshotsFolder']);
const server = http.createServer(requestListener);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
});