SUJINKO(고수진)

Upload new file

Showing 1 changed file with 63 additions and 0 deletions
var http = require('http');
var fs = require('fs');
var url = require('url');
var request = require('request');
var url2 = 'http://apis.data.go.kr/1262000/SafetyNewsList/getCountrySafetyNewsList';
var queryParams = `?${encodeURIComponent('ServiceKey')}=QTUBzVkK3FBFd0%2BLeWBpzJMZnUSZTn7xB1teg2G%2BcSHr9MxC3QMi1UxrA%2FFg%2FvkZgFBKxmt34D5YTQeunsRrYg%3D%3D`;/* Service Key*/
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
queryParams += '&' + encodeURIComponent('title1') + '=' + encodeURIComponent('입국'); /* */
queryParams += '&' + encodeURIComponent('title2') + '=' + encodeURIComponent('코로나'); /* */
queryParams += '&' + encodeURIComponent('title3') + '=' + encodeURIComponent('운항'); /* */
queryParams += '&' + encodeURIComponent('title4') + '=' + encodeURIComponent('항공권'); /* */
queryParams += '&' + encodeURIComponent('title5') + '=' + encodeURIComponent('격리'); /* */
request({
url: url2 + queryParams,
method: 'GET'
}, function (error, response, body) {
//console.log('Status', response.statusCode);
//console.log('Headers', JSON.stringify(response.headers));
//console.log('Reponse received', body);
});
var app = http.createServer(function(request,response){
var _url = request.url;
var queryData = url.parse(url2, true).query;
if(request.url == '/'){
url = '/index.html';
}
if(request.url == '/favicon.ico'){
return response.writeHead(404);
}
response.writeHead(200);
var template = `
<!doctype html>
<html>
<head>
<title>어디로 가시나요? 해외로검진표!</title>
<meta charset="utf-8">
</head>
<body>
<h1>해외로검진표</h1>
<p>당신이 가고 싶은 곳, 지금 떠날 수 있을까요?
</p>
<form>
<div>어디로 가시나요? <br/> <input type type="text" name="3_destination" value=""> </div>
</form>
<div>
<div>${queryData.}</div>
</div>
</body>
</html>
`;
});
app.listen(3000);