장주현

add papago-api function

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,10 +17,30 @@ app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res){
//res.send('hello world');
res.render('index');
});
//app.use('/', indexRoute);
app.listen(PORT, function(){
console.log('listen',PORT);
});
\ No newline at end of file
});
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
......
......@@ -17,7 +17,7 @@
// iframe을 넣은 element를 안보이게 한다.
element_wrap.style.display = 'none';
}
function sample3_execDaumPostcode() {
// 현재 scroll 위치를 저장해놓는다.
var currentScroll = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
......
......@@ -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
......