-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (51 loc) · 1.73 KB
/
app.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const port = 3000;
var express = require('express'),
helmet = require('helmet'),
formidable = require('formidable'),
fs = require('fs'),
extractor = require('unfluff'),
PythonShell = require('python-shell'),
request = require('request'),
bodyParser = require('body-parser');
var app = express(), form, link;
var firstRun = true;
const resumePdfPath = __dirname + "/data/resumePDF.pdf",
resumeTxtPath = __dirname + "/data/resume.txt",
descrPath = __dirname + "/data/jobDescr.txt";
var filePath, resumeJson, resumeText, resumeAuthor, descrText, jobReqs, matchJson, txt;
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static('public'));
app.use(helmet());
app.set("view engine", "ejs");
////////////////////////////
app.get('/', (req, res) => {
res.render('index');
});
app.post('/uncnn', (req, res) => {
form = new formidable.IncomingForm();
form.parse(req);
form.on('fileBegin', (name, file) => {
file.path = resumePdfPath;
});
form.on('file', (name, file) => {
(new PythonShell('src/myResume.py')).on('message', (message) => {
resumeJson = JSON.parse(message);
resumeText = resumeJson['text'];
resumeAuthor = resumeText.split('\n')[1] || resumeText.split('\n')[0] || 'YOU';
fs.writeFile(resumeTxtPath, resumeText, function(err) {
if(err) {
return console.log(err);
}
});
});
});
form.on('end', (name, file) => res.render('main'));
});
app.post('/home', (req, res) => {
firstRun = true;
res.render('main');
});
////////////////////////////
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});