Merge branch 'master' of ssh://khuhub.khu.ac.kr:12959/2019102236/WhereUR
Showing
3 changed files
with
0 additions
and
202 deletions
app.js
deleted
100644 → 0
1 | -var express = require('express') | ||
2 | - , http = require('http') | ||
3 | - , path = require('path'); | ||
4 | - | ||
5 | -var request = require('request'); | ||
6 | - | ||
7 | -var bodyParser = require('body-parser') | ||
8 | - , cookieParser = require('cookie-parser') | ||
9 | - , static = require('serve-static') | ||
10 | - , errorHandler = require('errorhandler'); | ||
11 | - | ||
12 | - | ||
13 | -var expressSession = require('express-session'); | ||
14 | - | ||
15 | -var app = express(); | ||
16 | - | ||
17 | - | ||
18 | -app.set('port', process.env.PORT || 3000); | ||
19 | - | ||
20 | -// body-parser를 이용해 application/x-www-form-urlencoded 파싱 | ||
21 | -app.use(bodyParser.urlencoded({ extended: false })) | ||
22 | - | ||
23 | -// body-parser를 이용해 application/json 파싱 | ||
24 | -app.use(bodyParser.json()) | ||
25 | - | ||
26 | -// public 폴더를 static으로 오픈 | ||
27 | -app.use('/public', static(path.join(__dirname, 'public'))); | ||
28 | - | ||
29 | -// cookie-parser 설정 | ||
30 | -app.use(cookieParser()); | ||
31 | - | ||
32 | -// 세션 설정 | ||
33 | -app.use(expressSession({ | ||
34 | - secret:'my key', | ||
35 | - resave:true, | ||
36 | - saveUninitialized:true | ||
37 | -})); | ||
38 | - | ||
39 | - | ||
40 | -// 라우터 객체 참조 | ||
41 | -var router = express.Router(); | ||
42 | - | ||
43 | -router.route('/process/map').get(function(req, res){ | ||
44 | - console.log('process/map 호출됨'); | ||
45 | -}); | ||
46 | - | ||
47 | - | ||
48 | -app.use('/', router); | ||
49 | - | ||
50 | -var url1 = 'http://data.ex.co.kr/openapi/odtraffic/trafficAmountByCongest'; | ||
51 | -var queryParams1 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ | ||
52 | -queryParams1 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */ | ||
53 | - | ||
54 | -request({ | ||
55 | - url: url1 + queryParams1, | ||
56 | - method: 'GET' | ||
57 | -}, function (error, response, body) { | ||
58 | - console.log('Status', response.statusCode); | ||
59 | - console.log('Headers', JSON.stringify(response.headers)); | ||
60 | - console.log('Reponse received', body); | ||
61 | - var obj = JSON.parse(body); | ||
62 | - console.log(obj); | ||
63 | - console.log(obj.list[0]) | ||
64 | -}); | ||
65 | - | ||
66 | - | ||
67 | - | ||
68 | -var url2 = 'http://data.ex.co.kr/openapi/safeDriving/forecast'; | ||
69 | -var queryParams2 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ | ||
70 | -queryParams2 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */ | ||
71 | - | ||
72 | -request({ | ||
73 | - url: url2 + queryParams2, | ||
74 | - method: 'GET' | ||
75 | -}, function (error, response, body) { | ||
76 | - console.log('Status', response.statusCode); | ||
77 | - console.log('Headers', JSON.stringify(response.headers)); | ||
78 | - console.log('Reponse received', body); | ||
79 | - var obj = JSON.parse(body); | ||
80 | - console.log(obj); | ||
81 | - console.log(obj.list[0]) | ||
82 | -}); | ||
83 | - | ||
84 | -var url3 = 'http://data.ex.co.kr/openapi/trafficapi/trafficAll'; | ||
85 | -var queryParams3 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ | ||
86 | -queryParams3 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */ | ||
87 | - | ||
88 | -request({ | ||
89 | - url: url3 + queryParams3, | ||
90 | - method: 'GET' | ||
91 | - | ||
92 | -}, function (error, response, body) { | ||
93 | - console.log('Status', response.statusCode); | ||
94 | - console.log('Headers', JSON.stringify(response.headers)); | ||
95 | - console.log('Reponse received', body); | ||
96 | - var obj = JSON.parse(body); | ||
97 | - console.log(obj); | ||
98 | - console.log(obj.trafficAll[0]); | ||
99 | -}); | ||
100 | - | ||
101 | - | ||
102 | -var url4 = 'http://data.ex.co.kr/openapi/trafficapi/trafficRegion'; | ||
103 | -var queryParams4 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ | ||
104 | -queryParams4 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */ | ||
105 | - | ||
106 | -request({ | ||
107 | - url: url4 + queryParams4, | ||
108 | - method: 'GET' | ||
109 | - | ||
110 | -}, function (error, response, body) { | ||
111 | - console.log('Status', response.statusCode); | ||
112 | - console.log('Headers', JSON.stringify(response.headers)); | ||
113 | - console.log('Reponse received', body); | ||
114 | - var obj = JSON.parse(body); | ||
115 | - console.log(obj); | ||
116 | - console.log(obj.trafficRegion[0]); | ||
117 | -}); | ||
118 | - | ||
119 | - | ||
120 | - | ||
121 | -var url5 = 'http://data.ex.co.kr/openapi/business/conveniServiceArea'; | ||
122 | -var queryParams5 = '?' + encodeURIComponent('key') + '=4365330273'; /* Service Key*/ | ||
123 | -queryParams5 += '&' + encodeURIComponent('type') + '=' + encodeURIComponent('json'); /* */ | ||
124 | - | ||
125 | -request({ | ||
126 | - url: url5 + queryParams5, | ||
127 | - method: 'GET' | ||
128 | - | ||
129 | -}, function (error, response, body) { | ||
130 | - console.log('Status', response.statusCode); | ||
131 | - console.log('Headers', JSON.stringify(response.headers)); | ||
132 | - console.log('Reponse received', body); | ||
133 | - var obj = JSON.parse(body); | ||
134 | - console.log(obj); | ||
135 | - console.log(obj.list[0]); | ||
136 | -}); | ||
137 | - | ||
138 | - | ||
139 | - | ||
140 | - | ||
141 | - | ||
142 | - | ||
143 | - | ||
144 | -// Express 서버 시작 | ||
145 | -http.createServer(app).listen(app.get('port'), function(){ | ||
146 | - console.log('서버가 시작되었습니다. 포트 : ' + app.get('port')); | ||
147 | - | ||
148 | - | ||
149 | - }); | ||
150 | - |
package.json
deleted
100644 → 0
1 | -{ | ||
2 | - "name": "whereur", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "app.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | - }, | ||
9 | - "repository": { | ||
10 | - "type": "git", | ||
11 | - "url": "ssh://git@khuhub.khu.ac.kr:12959/2019102236/WhereUR.git" | ||
12 | - }, | ||
13 | - "author": "", | ||
14 | - "license": "ISC", | ||
15 | - "dependencies": { | ||
16 | - "body-parser": "^1.19.0", | ||
17 | - "cookie-parser": "^1.4.5", | ||
18 | - "crypto": "^1.0.1", | ||
19 | - "errorhandler": "^1.5.1", | ||
20 | - "express": "^4.17.1", | ||
21 | - "express-error-handler": "^1.1.0", | ||
22 | - "express-session": "^1.17.1", | ||
23 | - "http": "0.0.1-security", | ||
24 | - "mongoose": "^5.9.16", | ||
25 | - "path": "^0.12.7", | ||
26 | - "request": "^2.88.2" | ||
27 | - } | ||
28 | -} |
public/map.html
deleted
100644 → 0
1 | -<!DOCTYPE html> | ||
2 | -<html> | ||
3 | -<head> | ||
4 | - <meta charset="utf-8"/> | ||
5 | - <title>Kakao 지도 시작하기</title> | ||
6 | -</head> | ||
7 | -<body> | ||
8 | - <form method="get" action="/process/map"> | ||
9 | - <div id="map" style="width:800px;height:800px;"></div> | ||
10 | - <script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=b335546caf8f2178d70b550aee16f1ea"></script> | ||
11 | - <script> | ||
12 | - var container = document.getElementById('map'); | ||
13 | - var options = { | ||
14 | - center: new kakao.maps.LatLng(37.243210, 127.077108), | ||
15 | - level: 3 | ||
16 | - }; | ||
17 | - | ||
18 | - var map = new kakao.maps.Map(container, options); | ||
19 | - | ||
20 | - map.addOverlayMapTypeId(kakao.maps.MapTypeId.TRAFFIC); | ||
21 | - </script> | ||
22 | - </form> | ||
23 | -</body> | ||
24 | -</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment