-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderhtml.js
More file actions
31 lines (28 loc) · 839 Bytes
/
renderhtml.js
File metadata and controls
31 lines (28 loc) · 839 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
28
29
30
31
var fs = require('fs');
/* Function explicit declarations */
var notFound = function (response){
response.writeHead(404, {
'content-type': 'text/html'
});
response.write("<html>The specified resource was not found</html>");
response.end();
}
var render = function (request, response, file) {
fs.readFile('html/' + file, function (error, data) {
if (error)
notFound(response);
else {
console.log('html/' + file);
var str = "" + data;
data = str.replace("#{content}", "Magic Content");
response.write(data);
response.end();
}
});
}
/* Function exports */
module.exports = {
moduleName: "File",
render: render,
notFound: notFound
}