Toggle navigation
Toggle navigation
This project
Loading...
Sign in
LI WENHAO
/
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-30 18:20:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
503456007087c82c405d53fab7382d9213abaa80
50345600
1 parent
2ade78b9
Solve synchronization problem
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
37 deletions
main.js
search.js
test.js
main.js
View file @
5034560
...
...
@@ -26,6 +26,7 @@ app.post('/test/result',test.result_post);
/* inf */
app
.
get
(
'/search'
,
search
.
home_get
);
app
.
post
(
'/search'
,
search
.
home_post
);
app
.
get
(
'/search/result'
,
search
.
result_get
);
app
.
post
(
'/search/result'
,
search
.
result_post
);
...
...
search.js
View file @
5034560
var
key
=
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiMjAxNjMxMTYzIiwiYXV0aF9pZCI6IjIiLCJ0b2tlbl90eXBlIjoiQWNjZXNzVG9rZW4iLCJzZXJ2aWNlX2lkIjoiNDMwMDExMzkzIiwiWC1BcHAtUmF0ZS1MaW1pdCI6IjUwMDoxMCIsIm5iZiI6MTYzNDMwMTE0NCwiZXhwIjoxNjQ5ODUzMTQ0LCJpYXQiOjE2MzQzMDExNDR9.EEWMly4HZG_DY-aleMtDFVOOmbWl8uVmG1tHVM3c-BE"
var
chname
;
var
userId
;
var
username
;
var
kart_level
;
var
request
=
require
(
'request'
);
var
userId
=
[];
var
username
=
[];
exports
.
home_get
=
function
(
req
,
res
){
res
.
render
(
'search_home'
);
};
exports
.
result_post
=
function
(
req
,
res
){
chname
=
encodeURIComponent
(
req
.
body
.
test
);
exports
.
home_post
=
function
(
req
,
res
){
var
chname
=
encodeURIComponent
(
req
.
body
.
test
);
var
api_url
=
'https://api.nexon.co.kr/kart/v1.0/users/nickname/'
+
chname
;
var
request
=
require
(
'request'
);
var
options
=
{
url
:
api_url
,
headers
:{
Authorization
:
key
}
...
...
@@ -19,9 +15,8 @@ exports.result_post=function(req,res){
request
.
get
(
options
,
function
(
error
,
response
,
body
){
if
(
!
error
&&
response
.
statusCode
==
200
)
{
var
jsbody
=
JSON
.
parse
(
body
);
userId
=
jsbody
.
accessId
;
username
=
jsbody
.
name
;
kart_level
=
jsbody
.
level
;
userId
.
push
(
jsbody
.
accessId
);
username
.
push
(
jsbody
.
name
);
res
.
send
(
JSON
.
stringify
(
response
.
statusCode
));
}
else
{
...
...
@@ -30,9 +25,13 @@ exports.result_post=function(req,res){
});
}
exports
.
result_post
=
function
(
req
,
res
){
}
exports
.
result_get
=
function
(
req
,
res
)
{
var
api_url
=
"https://api.nexon.co.kr/kart/v1.0/users/"
+
userId
+
"/matches?start_date=&end_date= &offset=0&limit=10&match_types=7b9f0fd5377c38514dbb78ebe63ac6c3b81009d5a31dd569d1cff8f005aa881a"
;
var
request
=
require
(
'request'
);
var
api_url
=
"https://api.nexon.co.kr/kart/v1.0/users/"
+
userId
[
0
]
+
"/matches?start_date=&end_date= &offset=0&limit=10&match_types=7b9f0fd5377c38514dbb78ebe63ac6c3b81009d5a31dd569d1cff8f005aa881a"
;
userId
.
splice
(
0
,
1
);
var
options
=
{
//개인전만 검색하는 것임
url
:
api_url
,
...
...
@@ -41,7 +40,9 @@ exports.result_get = function (req, res) {
request
.
get
(
options
,
function
(
error
,
response
,
body
)
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
var
match
=
JSON
.
parse
(
body
);
res
.
render
(
'search_result'
,
{
name
:
username
,
level
:
kart_level
,
body
:
JSON
.
stringify
(
match
)
});
var
nickname
=
username
[
0
];
username
.
splice
(
0
,
1
);
res
.
render
(
'search_result'
,
{
name
:
nickname
,
body
:
JSON
.
stringify
(
match
)
});
}
else
{
res
.
send
(
"error :"
+
response
.
statusCode
);
...
...
test.js
View file @
5034560
var
vec
;
var
keyword
=
[];
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
<
vec
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
vec
temp
[
0
]
.
length
;
i
++
){
if
(
i
!=
2
&&
i
!=
3
&&
i
!=
4
&&
i
!=
5
&&
i
!=
10
&&
i
!=
11
)
temp
+=
vec
[
i
];
temp
+=
vec
temp
[
0
]
[
i
];
}
console
.
log
(
vectemp
);
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
);
res
.
render
(
'test_result'
,{
url
:
url
,
body
:
list
[
rand
],
keyword
:
keyword
});
var
keyw
=
keytemp
[
0
];
keytemp
.
splice
(
0
,
1
);
res
.
render
(
'test_result'
,{
url
:
url
,
body
:
list
[
rand
],
keyword
:
keyw
});
});
};
\ No newline at end of file
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