forked from JaredCubilla/jsonresume-theme-classy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
25 lines (22 loc) · 678 Bytes
/
server.js
File metadata and controls
25 lines (22 loc) · 678 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
var http = require("http");
var resume = require("resume-schema").resumeJson;
var theme = require("./index.js");
var fs = require('fs');
const spawn = require('child_process').spawn;
var port = 8080;
http.createServer(function(req, res) {
res.writeHead(200, {"Content-Type": "text/html"});
res.end(render());
}).listen(port);
console.log("Serving theme");
console.log("Preview: http://localhost:8080/");
spawn('open', ['http://localhost:8080/']);
function render() {
try {
var private_resume = JSON.parse(fs.readFileSync("../json-resume/resume.json", "utf-8"));
return theme.render(private_resume);
} catch(e) {
console.log("Error: " + e.message);
return "";
}
}