-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (28 loc) · 1.12 KB
/
server.js
File metadata and controls
29 lines (28 loc) · 1.12 KB
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
const http = require('http');
const fs = require('fs');
const idDoc = fs.readFileSync('./public/id.ttl', 'utf8');
const accessNeeds = fs.readFileSync('./public/access-needs.ttl', 'utf8');
const foafProfileShex = fs.readFileSync('./public/foafProfile.shex', 'utf8');
const descriptionsEn = fs.readFileSync('./public/descriptions-en.ttl', 'utf8');
http.createServer((req, res) => {
console.log(req.url);
console.log(req.headers);
if (req.url === '/id.ttl') {
res.writeHead(200, { 'Content-Type': 'text/turtle' });
res.write(idDoc);
} else if (req.url === "/access-needs.ttl") {
res.writeHead(200, { 'Content-Type': 'text/turtle' });
res.write(accessNeeds);
} else if (req.url === "/foafProfile.shex") {
res.writeHead(200, { 'Content-Type': 'text/shex' });
res.write(foafProfileShex);
} else if (req.url === "/descriptions-en.ttl") {
res.writeHead(200, { 'Content-Type': 'text/turtle' });
res.write(descriptionsEn);
} else {
res.writeHead(404, { 'Content-Type': 'text/html' });
res.write('Not found: ' + req.url);
console.log('Not found: ' + req.url);
}
res.end();
}).listen(3009);