test.js
1.41 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var vectemp=[];
var keytemp=[];
exports.home_get=function(req,res){
res.render('test_home');
};
exports.result_post = function (req, res) {
var vec = req.body.test;
if (vec == null) {
res.status(404).send("Not Found");
}
else {
var item = ["empty", "추억", "empty", "신중함", "안정적", "empty", "열정", "책임감", "아이템", "스피드", "믿음직", "호기심", "헌신적", "자유로움"];
var keyword = [];
for (var i = 1; i < vec.length; i++) {
if (i % 2 != 0) {
if (vec[i] == "1") {
keyword.push(item[i - 1]);
}
else {
keyword.push(item[i]);
}
}
}
vectemp.push(vec);
keytemp.push(keyword);
res.send("success");
}
};
exports.result_get=function(req,res){
var temp="";
for(var i=0; i<vectemp[0].length; i++){
if(i!=2 && i!=3 && i!=4 && i!=5 && i!=10 && i!=11)
temp+=vectemp[0][i];
}
vectemp.splice(0,1);
var fs=require('fs');
var url="metadata/kart_find"+temp+"/";
var testFolder="views/metadata/kart_find"+temp;
fs.readdir(testFolder, function(error, list){
var rand=Math.floor(Math.random()*list.length);
var keyw=keytemp[0];
keytemp.splice(0,1);
res.render('test_result',{url:url,body:list[rand],keyword:keyw});
});
};