Merge branch 'feature/BoxOfficeAPI' into 'master'
Feature/box office api First Merge from feature/BoxOfficeAPI to master See merge request !5
Showing
2 changed files
with
67 additions
and
0 deletions
BoxOffice/app.js
0 → 100644
1 | +let express = require('express'); | ||
2 | +let app = express(); | ||
3 | +let request = require('request'); | ||
4 | +let bodyParser = require('body-parser'); | ||
5 | +const { response } = require('express'); | ||
6 | + | ||
7 | +app.use(bodyParser.urlencoded({ extended: false })); | ||
8 | +app.use(bodyParser.json()); | ||
9 | + | ||
10 | + | ||
11 | +let today = new Date(); | ||
12 | +let year = today.getFullYear(); | ||
13 | +let month = ("0" + (1 + today.getMonth())).slice(-2); | ||
14 | +let day = ("0" + today.getDate()).slice(-2); | ||
15 | +let date = year + month + day-1; | ||
16 | +//YYYYMMDD | ||
17 | + | ||
18 | +//console.log(date); | ||
19 | + | ||
20 | +let key = ""; | ||
21 | +let url = "http://kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=" + key + "&targetDt=" + date + "&itemPerPage="; | ||
22 | +//let rank = 5 | ||
23 | +//apiurl = url + date + "&itemPerPage=" +rank-> "출력할 박스오피스 순위(5: 5위 까지, 10 : 10위 까지.../기본, 최대 10)" | ||
24 | +//console.log(url); | ||
25 | + | ||
26 | +let options = { | ||
27 | + 'method' : 'GET', | ||
28 | + 'url' : url // + rank | ||
29 | +}; | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | +app.get('/BoxOffice',(req, res) => { | ||
34 | + options.url = url + req.body.rank; | ||
35 | + //console.log(req.body.rank); | ||
36 | + request(options, function (error, response, body){ | ||
37 | + if (error){ | ||
38 | + throw new Error(error); | ||
39 | + } | ||
40 | + let info = JSON.parse(body); | ||
41 | + res.send(info); | ||
42 | + }); | ||
43 | +}) | ||
44 | + | ||
45 | +// 박스오피스 순위 출력 | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | +let server = app.listen(80); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
BoxOffice/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "Testing BoxOffice API", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "index.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "author": "", | ||
10 | + "license": "ISC", | ||
11 | + "dependencies": { | ||
12 | + "body-parser": "^1.17.1", | ||
13 | + "express": "^4.15.2" | ||
14 | + } | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment