장주현

post from index.ejs

const express = require('express');
const request = require('request');
const fs = require('fs');
const bodyParser = require('body-parser');
const app = express();
const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const client_id = 'cIZBOTfISMHEyygh_NHp';
const client_secret = '8D32UNGgYp';
const PAPAGO_ID = 'cIZBOTfISMHEyygh_NHp';
const PAPAGO_SECRET = '8D32UNGgYp';
const PORT = process.env.PORT || 3000;
//const indexRoute = require("./routes/index");
app.use(bodyParser.urlencoded({extended: true}));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));
//var postcode = require(postcode.v2.html);
//const fs = require('filesystem')
var addressK, addressE;
var detailaddressK, detailaddressE;
var extraaddressK, extraaddressE;
var zipcode;
app.get('/', function(req, res){
//res.send('hello world');
......@@ -20,8 +26,31 @@ app.use(express.static(__dirname + '/public'));
});
app.get('/', function(req, res){
res.render('index');
});
//app.use('/', indexRoute);
app.post('/', function(req,res){
console.log(req.body);
zipcode = req.body.zipcode;
addressK = req.body.addressK;
detailaddressK = req.body.detailaddressK;
extraaddressK = req.body.extraaddressK;
console.log(addressK);
addressE = trans(addressK, detailaddressE);
//trans(detailaddressK, detailaddressE);
//trans(extraaddressK, extraaddressE);
setTimeout(function(){console.log("set: " +detailaddressE)},500);
console.log("address: " + addressE);
console.log("detail: " + detailaddressE);
});
app.listen(PORT, function(){
console.log('listen',PORT);
});
......@@ -41,6 +70,8 @@ function trans(message, totrans){
if(!error && response.statusCode == 200) {
console.log(body.message);
totrans = body.message.result.translatedText;
return totrans;
}
});
};
\ No newline at end of file
......
<form>
<form action="" method="POST">
<input type="text" name="zipcode" id="sample3_postcode" placeholder="우편번호">
<input type="button" onclick="sample3_execDaumPostcode()" value="우편번호 찾기"><br>
<input type="text" name="addressK" id="sample3_address" placeholder="주소"><br>
......@@ -8,8 +8,8 @@
<input type="text" name="extraaddressK" id="sample3_extraAddress" placeholder="참고항목">
<p> 사용할 해외 쇼핑몰 선택 후 변환</p>
<input type="radio" id="selshop" name="os" value="amazon" checked="checked">Amazon
<input type="radio" id="selshop" name="os" value="ebay">Ebay
<input type="radio" name="os" value="amazon" checked="checked">Amazon
<input type="radio" name="os" value="ebay">Ebay
<input type="submit" value="주소 변환">
</form>
<p> 사용할 해외 쇼핑몰 선택 후 변환</p>
......