임승현

Merge branch 'feature/BoxOfficeAPI' into 'master'

Feature/box office api

First Merge from feature/BoxOfficeAPI to master

See merge request !5
let express = require('express');
let app = express();
let request = require('request');
let bodyParser = require('body-parser');
const { response } = require('express');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
let today = new Date();
let year = today.getFullYear();
let month = ("0" + (1 + today.getMonth())).slice(-2);
let day = ("0" + today.getDate()).slice(-2);
let date = year + month + day-1;
//YYYYMMDD
//console.log(date);
let key = "";
let url = "http://kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=" + key + "&targetDt=" + date + "&itemPerPage=";
//let rank = 5
//apiurl = url + date + "&itemPerPage=" +rank-> "출력할 박스오피스 순위(5: 5위 까지, 10 : 10위 까지.../기본, 최대 10)"
//console.log(url);
let options = {
'method' : 'GET',
'url' : url // + rank
};
app.get('/BoxOffice',(req, res) => {
options.url = url + req.body.rank;
//console.log(req.body.rank);
request(options, function (error, response, body){
if (error){
throw new Error(error);
}
let info = JSON.parse(body);
res.send(info);
});
})
// 박스오피스 순위 출력
let server = app.listen(80);
\ No newline at end of file
{
"name": "Testing BoxOffice API",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2"
}
}
\ No newline at end of file