Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김명주
/
kartrider
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김명주
2021-11-26 15:50:56 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
74ef81b74e66dccc20da3810803ed7106ea129b3
74ef81b7
1 parent
952be819
Split main js file
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
0 deletions
main.js
test.js
main.js
0 → 100644
View file @
74ef81b
var
express
=
require
(
'express'
);
var
app
=
express
();
var
test
=
require
(
'./test.js'
);
var
search
=
require
(
'./search.js'
);
const
bodyParser
=
require
(
'body-parser'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
// URL 인코딩 안함
app
.
use
(
bodyParser
.
json
());
// json 타입으로 파싱하게 설정
app
.
use
(
'/'
,
express
.
static
(
'views'
));
app
.
use
(
'/test/result'
,
express
.
static
(
'views'
));
app
.
use
(
'/search/result'
,
express
.
static
(
'views'
));
app
.
set
(
'views'
,
__dirname
+
'/views'
);
app
.
set
(
'view engine'
,
'ejs'
);
/* kart recommendation */
app
.
get
(
'/test'
,
test
.
home_get
);
app
.
get
(
'/test/result'
,
test
.
result_get
);
app
.
post
(
'/test/result'
,
test
.
result_post
);
/* inf */
app
.
get
(
'/search'
,
search
.
home_get
);
app
.
get
(
'/search/result'
,
search
.
result_get
);
app
.
post
(
'/search/result'
,
search
.
result_post
);
/* home page */
app
.
get
(
"/"
,(
req
,
res
)
=>
{
res
.
render
(
'main_home'
);
});
/* server */
app
.
listen
(
"8080"
,
function
(
req
,
res
){
console
.
log
(
'server listening at port no. 8080'
);
});
test.js
0 → 100644
View file @
74ef81b
var
vec
;
var
keyword
=
[];
exports
.
home_get
=
function
(
req
,
res
){
res
.
render
(
'test_home'
);
};
exports
.
result_get
=
function
(
req
,
res
){
var
temp
=
""
;
for
(
var
i
=
0
;
i
<
vec
.
length
;
i
++
){
if
(
i
!=
2
&&
i
!=
3
&&
i
!=
4
&&
i
!=
5
&&
i
!=
10
&&
i
!=
11
)
temp
+=
vec
[
i
];
}
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
);
res
.
render
(
'test_result'
,{
url
:
url
,
body
:
list
[
rand
],
keyword
:
keyword
});
});
};
exports
.
result_post
=
function
(
req
,
res
){
vec
=
req
.
body
.
test
;
var
item
=
[
"empty"
,
"추억"
,
"empty"
,
"신중함"
,
"안정적"
,
"empty"
,
"열정"
,
"책임감"
,
"아이템"
,
"스피드"
,
"믿음직"
,
"호기심"
,
"헌신적"
,
"자유로움"
];
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
]);
}
}
}
};
\ No newline at end of file
Please
register
or
login
to post a comment