Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장주현
/
Amazon_Shopping_Helper
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
장주현
2020-06-14 17:52:04 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2e4293bb271dc92740fc59a03c7440cf71339ab2
2e4293bb
1 parent
74332c41
add papago-api function
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
app.js
views/index.ejs
views/index.js
app.js
View file @
2e4293b
const
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
app
=
express
();
const
PAPAGO_URL
=
'https://openapi.naver.com/v1/papago/n2mt'
const
client_id
=
'cIZBOTfISMHEyygh_NHp'
;
const
client_secret
=
'8D32UNGgYp'
;
const
PORT
=
process
.
env
.
PORT
||
3000
;
//const indexRoute = require("./routes/index");
...
...
@@ -13,6 +17,7 @@ app.use(express.static(__dirname + '/public'));
app
.
get
(
'/'
,
function
(
req
,
res
){
//res.send('hello world');
res
.
render
(
'index'
);
});
//app.use('/', indexRoute);
...
...
@@ -20,3 +25,22 @@ app.use(express.static(__dirname + '/public'));
app
.
listen
(
PORT
,
function
(){
console
.
log
(
'listen'
,
PORT
);
});
function
trans
(
message
,
totrans
){
request
.
post
(
{
url
:
PAPAGO_URL
,
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded; charset=UTF-8'
,
'X-Naver-Client-Id'
:
`
${
PAPAGO_ID
}
`
,
'X-Naver-Client-Secret'
:
`
${
PAPAGO_SECRET
}
`
},
body
:
'source=ko&target=en&text='
+
message
,
json
:
true
},(
error
,
response
,
body
)
=>
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
console
.
log
(
body
.
message
);
totrans
=
body
.
message
.
result
.
translatedText
;
}
});
}
\ No newline at end of file
...
...
views/index.ejs
View file @
2e4293b
views/index.js
View file @
2e4293b
...
...
@@ -3,6 +3,7 @@ const router = express.Router();
router
.
get
(
'/'
,
function
(
req
,
res
){
res
.
render
(
'index'
);
console
.
log
(
"trtt"
)
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment