Eunsu486

Merge branch 'eunsu' into 'master'

Eunsu

Merge From eunsu into master

See merge request !3
...@@ -3,42 +3,36 @@ var express = require('express'); ...@@ -3,42 +3,36 @@ var express = require('express');
3 var path = require('path'); 3 var path = require('path');
4 var cookieParser = require('cookie-parser'); 4 var cookieParser = require('cookie-parser');
5 var logger = require('morgan'); 5 var logger = require('morgan');
6 -
7 var indexRouter = require('./routes/index'); 6 var indexRouter = require('./routes/index');
8 var usersRouter = require('./routes/users'); 7 var usersRouter = require('./routes/users');
9 -//var categoryRouter = require('./routes/category');
10 var categoryRouter = require('./routes/category'); 8 var categoryRouter = require('./routes/category');
11 - 9 +var vendorRounter = require('./routes/vendors');
12 var app = express(); 10 var app = express();
13 - 11 +var bodyParser = require('body-parser');
14 // view engine setup 12 // view engine setup
15 app.set('views', path.join(__dirname, 'views')); 13 app.set('views', path.join(__dirname, 'views'));
16 app.set('view engine', 'ejs'); 14 app.set('view engine', 'ejs');
17 -
18 app.use(logger('dev')); 15 app.use(logger('dev'));
19 app.use(express.json()); 16 app.use(express.json());
20 app.use(express.urlencoded({ extended: false })); 17 app.use(express.urlencoded({ extended: false }));
21 app.use(cookieParser()); 18 app.use(cookieParser());
22 app.use(express.static(path.join(__dirname, 'public'))); 19 app.use(express.static(path.join(__dirname, 'public')));
23 -
24 app.use('/', indexRouter); 20 app.use('/', indexRouter);
25 app.use('/users', usersRouter); 21 app.use('/users', usersRouter);
26 app.use('/category', categoryRouter); 22 app.use('/category', categoryRouter);
27 - 23 +app.use('/vendors/bootstrap', express.static(path.join(__dirname, "./node_modules/bootstrap/dist")));
24 +app.use(bodyParser.urlencoded({ extended: false }));
28 // catch 404 and forward to error handler 25 // catch 404 and forward to error handler
29 app.use(function (req, res, next) { 26 app.use(function (req, res, next) {
30 next(createError(404)); 27 next(createError(404));
31 }); 28 });
32 -
33 // error handler 29 // error handler
34 app.use(function (err, req, res, next) { 30 app.use(function (err, req, res, next) {
35 // set locals, only providing error in development 31 // set locals, only providing error in development
36 res.locals.message = err.message; 32 res.locals.message = err.message;
37 res.locals.error = req.app.get('env') === 'development' ? err : {}; 33 res.locals.error = req.app.get('env') === 'development' ? err : {};
38 -
39 // render the error page 34 // render the error page
40 res.status(err.status || 500); 35 res.status(err.status || 500);
41 res.render('error'); 36 res.render('error');
42 }); 37 });
43 -
44 module.exports = app; 38 module.exports = app;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 "_resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz", 22 "_resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
23 "_shasum": "927d2f6947f7f1c19a316dd8eea3614e8b18f8e9", 23 "_shasum": "927d2f6947f7f1c19a316dd8eea3614e8b18f8e9",
24 "_spec": "xml-js@^1.6.11", 24 "_spec": "xml-js@^1.6.11",
25 - "_where": "C:\\Users\\se051\\OneDrive\\바탕 화면\\나의 대학라이프\\오픈소스SW개발\\텀프\\animal-Info", 25 + "_where": "C:\\Users\\owterm\\animal-Info",
26 "author": { 26 "author": {
27 "name": "Yousuf Almarzooqi", 27 "name": "Yousuf Almarzooqi",
28 "email": "ysf953@gmail.com" 28 "email": "ysf953@gmail.com"
......
1 { 1 {
2 - "_from": "xml2js", 2 + "_from": "xml2js@^0.4.23",
3 "_id": "xml2js@0.4.23", 3 "_id": "xml2js@0.4.23",
4 "_inBundle": false, 4 "_inBundle": false,
5 "_integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", 5 "_integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
6 "_location": "/xml2js", 6 "_location": "/xml2js",
7 "_phantomChildren": {}, 7 "_phantomChildren": {},
8 "_requested": { 8 "_requested": {
9 - "type": "tag", 9 + "type": "range",
10 "registry": true, 10 "registry": true,
11 - "raw": "xml2js", 11 + "raw": "xml2js@^0.4.23",
12 "name": "xml2js", 12 "name": "xml2js",
13 "escapedName": "xml2js", 13 "escapedName": "xml2js",
14 - "rawSpec": "", 14 + "rawSpec": "^0.4.23",
15 "saveSpec": null, 15 "saveSpec": null,
16 - "fetchSpec": "latest" 16 + "fetchSpec": "^0.4.23"
17 }, 17 },
18 "_requiredBy": [ 18 "_requiredBy": [
19 "#USER", 19 "#USER",
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
21 ], 21 ],
22 "_resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", 22 "_resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
23 "_shasum": "a0c69516752421eb2ac758ee4d4ccf58843eac66", 23 "_shasum": "a0c69516752421eb2ac758ee4d4ccf58843eac66",
24 - "_spec": "xml2js", 24 + "_spec": "xml2js@^0.4.23",
25 - "_where": "C:\\Users\\se051\\OneDrive\\바탕 화면\\나의 대학라이프\\오픈소스SW개발\\텀프\\animal-Info", 25 + "_where": "C:\\Users\\owterm\\animal-Info",
26 "author": { 26 "author": {
27 "name": "Marek Kubica", 27 "name": "Marek Kubica",
28 "email": "marek@xivilization.net", 28 "email": "marek@xivilization.net",
......
...@@ -4,309 +4,242 @@ var request = require('request'); ...@@ -4,309 +4,242 @@ var request = require('request');
4 const convert = require('xml-js'); 4 const convert = require('xml-js');
5 require('dotenv').config(); 5 require('dotenv').config();
6 var urlencode = require('urlencode'); 6 var urlencode = require('urlencode');
7 -
8 /* GET home page. */ 7 /* GET home page. */
9 let GU_CODE; 8 let GU_CODE;
10 let ANIMAL_INFO_API_KEY = process.env.REACT_APP_API_KEY; 9 let ANIMAL_INFO_API_KEY = process.env.REACT_APP_API_KEY;
11 -let user_gu; 10 +let gu_select;
12 -let user_latitude;
13 -let user_longitude;
14 -
15 -//동물병원
16 -router.post('/hospital', function(req, res){
17 - //gu 받아오기
18 - var body = req.body;
19 - var gu_select = body.user_gu;
20 - var menu = '동물병원';
21 11
22 - // encoding for url
23 - var menu_encode = urlencode(menu);
24 - var gu_select_encode = urlencode(gu_select);
25 12
13 +// 사용자가 index 페이지에서 주소선택. 입력값받아오는 함수
14 +router.post('/', function (req, res) {
15 + var body = req.body;
16 + gu_select = body.user_gu;
17 + console.log(gu_select);
18 + res.send('Good');
19 +});
20 +//동물병원 함수
21 +router.get('/hospital', function (req, res) {
26 //api 22 //api
27 - let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=200&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`; 23 + var gu_select_encode = urlencode(gu_select);
28 - request(pet_url, function(err, response, body){ 24 + let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EB%8F%99%EB%AC%BC%EB%B3%91%EC%9B%90&where=${gu_select_encode}`;
29 - if(err) { 25 + request(pet_url, function (err, response, body) {
26 + if (err) {
30 console.log(`err => ${err}`) 27 console.log(`err => ${err}`)
31 } 28 }
32 else { 29 else {
33 - if(res.statusCode == 200) { 30 + if (res.statusCode == 200) {
34 - var hospital_list = []; 31 + let hospital_list = [];
35 - var titles = ''; 32 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
36 - 33 + var petJson = JSON.parse(result)
37 - var result = convert.xml2json(body, {compact: true, spaces: 4});
38 - var petJson = JSON.parse(result);
39 var itemList = petJson.response.body.items; 34 var itemList = petJson.response.body.items;
40 - var numRows = petJson.response.body.totalCount._text; //개수 35 + var numRows = itemList.item.length; //개수
41 - 36 + for (i = 0; i < numRows; i++) {
42 - if (numRows == 1){
43 // state 정상인 것만 추리기 37 // state 정상인 것만 추리기
44 - if (itemList.item.state._text == '정상'){ 38 + if (itemList.item[i].state._text == '정상') {
45 - appliance_list.push(itemList.item); 39 + hospital_list.push(itemList.item[i]);
46 - }
47 } 40 }
48 - else if (numRows == 0){}
49 - else {
50 - for (i=0; i<numRows; i++){
51 - // state 정상인 것만 추리기
52 - if (itemList.item[i].state._text == '정상'){
53 - appliance_list.push(itemList.item[i]);
54 } 41 }
55 - }
56 - }
57 -
58 //테스트용 console.log 42 //테스트용 console.log
59 - for(i=0; i<hospital_list.length; i++){ 43 + var titles = '';
60 - titles = titles+hospital_list[i].title._text+'\n'; 44 + for (i = 0; i < hospital_list.length; i++) {
45 + titles = titles + hospital_list[i].title._text + '\n';
61 } 46 }
62 - if (titles == '') {console.log('nothing');} 47 + console.log(titles);
63 - else {console.log(titles); } 48 + res.render('result', { category: 'hospital', titles: titles, hospital_list: hospital_list });
64 } 49 }
65 } 50 }
66 - res.render('result', { category: 'hospital', titles: titles, hospital_list: hospital_list });
67 }) 51 })
68 - }); 52 +});
69 - 53 +//동물약국
70 - //동물약국 54 +router.get('/medicine', function (req, res) {
71 -router.post('/medicine', function(req, res){ 55 + //api
72 - //gu 받아오기 56 + var gu_select_encode = urlencode(gu_select);
73 - var body = req.body;
74 - var gu_select = body.user_gu;
75 var menu = '동물약국'; 57 var menu = '동물약국';
76 -
77 - // encoding for url
78 var menu_encode = urlencode(menu); 58 var menu_encode = urlencode(menu);
79 - var gu_select_encode = urlencode(gu_select); 59 + let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
80 - 60 + request(pet_url, function (err, response, body) {
81 - //api 61 + if (err) {
82 - let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=200&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
83 - request(pet_url, function(err, response, body){
84 - if(err) {
85 console.log(`err => ${err}`) 62 console.log(`err => ${err}`)
86 } 63 }
87 else { 64 else {
88 - if(res.statusCode == 200) { 65 + if (res.statusCode == 200) {
89 - var medicine_list = []; 66 + let category_list = [];
90 - var titles = ''; 67 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
91 - 68 + var petJson = JSON.parse(result)
92 - var result = convert.xml2json(body, {compact: true, spaces: 4});
93 - var petJson = JSON.parse(result);
94 var itemList = petJson.response.body.items; 69 var itemList = petJson.response.body.items;
95 - var numRows = petJson.response.body.totalCount._text; //개수 70 + var numRows = itemList.item.length; //개수
96 - 71 + for (i = 0; i < numRows; i++) {
97 - if (numRows == 1){
98 // state 정상인 것만 추리기 72 // state 정상인 것만 추리기
99 - if (itemList.item.state._text == '정상'){ 73 + if (itemList.item[i].state._text == '정상') {
100 - appliance_list.push(itemList.item); 74 + category_list.push(itemList.item[i]);
101 - }
102 } 75 }
103 - else if (numRows == 0){}
104 - else {
105 - for (i=0; i<numRows; i++){
106 - // state 정상인 것만 추리기
107 - if (itemList.item[i].state._text == '정상'){
108 - appliance_list.push(itemList.item[i]);
109 } 76 }
110 - }
111 - }
112 -
113 //테스트용 console.log 77 //테스트용 console.log
114 - for(i=0; i<medicine_list.length; i++){ 78 + var titles = '';
115 - titles = titles+medicine_list[i].title._text+'\n'; 79 + for (i = 0; i < category_list.length; i++) {
80 + titles = titles + category_list[i].title._text + '\n';
116 } 81 }
117 - if (titles == '') {console.log('nothing');} 82 + console.log(titles);
118 - else {console.log(titles); } 83 + res.render('result', { category: 'medicine', titles: titles, category_list: category_list });
119 } 84 }
120 } 85 }
121 - res.render('result', { category: 'medicine', titles: titles, medicine_list: medicine_list });
122 }) 86 })
123 - }); 87 +});
124 -
125 //의료기기 88 //의료기기
126 -router.post('/appliance', function(req, res){ 89 +router.get('/appliance', function (req, res) {
127 - //gu 받아오기
128 - var body = req.body;
129 - var gu_select = body.user_gu;
130 - var menu = "동물의료기기 판매 및 임대업체";
131 -
132 - // encoding for url
133 - var menu_encode = urlencode(menu);
134 - var gu_select_encode = urlencode(gu_select);
135 -
136 //api 90 //api
91 + var gu_select_encode = urlencode(gu_select);
92 + var menu = '동물의료기기';
93 + var menu_encode = urlencode(menu);
137 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`; 94 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
138 - request(pet_url, function(err, response, body){ 95 + request(pet_url, function (err, response, body) {
139 - if(err) { 96 + if (err) {
140 console.log(`err => ${err}`) 97 console.log(`err => ${err}`)
141 } 98 }
142 else { 99 else {
143 - if(res.statusCode == 200) { 100 + if (res.statusCode == 200) {
144 - var appliance_list = []; 101 + let appliance_list = [];
145 - var titles = ''; 102 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
146 - 103 + var petJson = JSON.parse(result)
147 - var result = convert.xml2json(body, {compact: true, spaces: 4});
148 - var petJson = JSON.parse(result);
149 var itemList = petJson.response.body.items; 104 var itemList = petJson.response.body.items;
150 var numRows = petJson.response.body.totalCount._text; //개수 105 var numRows = petJson.response.body.totalCount._text; //개수
151 106
152 - //------------------------------------------------- 107 + if (numRows == 1) {
153 - if (numRows == 1){
154 // state 정상인 것만 추리기 108 // state 정상인 것만 추리기
155 - if (itemList.item.state._text == '정상'){ 109 + if (itemList.item.state._text == '정상') {
156 appliance_list.push(itemList.item); 110 appliance_list.push(itemList.item);
157 } 111 }
158 } 112 }
159 - else if (numRows == 0){} 113 + else if (numRows == 0) { }
160 else { 114 else {
161 - for (i=0; i<numRows; i++){ 115 + for (i = 0; i < numRows; i++) {
162 // state 정상인 것만 추리기 116 // state 정상인 것만 추리기
163 - if (itemList.item[i].state._text == '정상'){ 117 + if (itemList.item[i].state._text == '정상') {
164 appliance_list.push(itemList.item[i]); 118 appliance_list.push(itemList.item[i]);
165 } 119 }
166 } 120 }
167 } 121 }
168 - //-----------------------------------------------
169 -
170 //테스트용 console.log 122 //테스트용 console.log
171 - for(i=0; i<appliance_list.length; i++){ 123 + var titles = '';
172 - titles = titles+appliance_list[i].title._text+'\n'; 124 + for (i = 0; i < appliance_list.length; i++) {
125 + titles = titles + appliance_list[i].title._text + '\n';
173 } 126 }
174 - if (titles == '') {console.log('nothing');} 127 + console.log(titles);
175 - else {console.log(titles); } 128 + res.render('result', { category: 'appliance', titles: titles, appliance_list: appliance_list });
176 -
177 } 129 }
178 } 130 }
179 - res.render('result', { category: 'appliance', titles: titles, appliance_list: appliance_list });
180 }) 131 })
181 - }); 132 +});
182 -
183 //체육시설 133 //체육시설
184 -router.post('/park', function(req, res){ 134 +router.get('/park', function (req, res) {
185 - //gu 받아오기 135 + var gu_select_encode = urlencode(gu_select);
186 - var body = req.body;
187 - var gu_select = body.user_gu;
188 var menu = ["생활체육관", "학교체육시설", "풋살장", "축구장"]; 136 var menu = ["생활체육관", "학교체육시설", "풋살장", "축구장"];
189 -
190 // encoding for url 137 // encoding for url
191 var menu_encode = []; 138 var menu_encode = [];
192 - for (var j = 0; j<menu.length;j++){ 139 + for (var j = 0; j < menu.length; j++) {
193 - menu_encode[j]=urlencode(menu[j]); 140 + menu_encode[j] = urlencode(menu[j]);
194 } 141 }
195 - var gu_select_encode = urlencode(gu_select);
196 142
197 //api 143 //api
198 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[0]}&where=${gu_select_encode}`; 144 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[0]}&where=${gu_select_encode}`;
199 - request(pet_url, function(err, response, body){ 145 + request(pet_url, function (err, response, body) {
200 - if(err) { 146 + if (err) {
201 console.log(`err => ${err}`) 147 console.log(`err => ${err}`)
202 } 148 }
203 else { 149 else {
204 - if(res.statusCode == 200) { 150 + if (res.statusCode == 200) {
205 var appliance_list = []; 151 var appliance_list = [];
206 var titles = ''; 152 var titles = '';
207 - 153 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
208 - var result = convert.xml2json(body, {compact: true, spaces: 4});
209 var petJson = JSON.parse(result) 154 var petJson = JSON.parse(result)
210 var itemList = petJson.response.body.items; 155 var itemList = petJson.response.body.items;
211 var numRows = petJson.response.body.totalCount._text; //개수 156 var numRows = petJson.response.body.totalCount._text; //개수
212 - 157 + if (numRows == 1) {
213 - if (numRows == 1){
214 appliance_list.push(itemList.item); 158 appliance_list.push(itemList.item);
215 } 159 }
216 - else if (numRows == 0){} 160 + else if (numRows == 0) { }
217 else { 161 else {
218 - for (i=0; i<numRows; i++){ 162 + for (i = 0; i < numRows; i++) {
219 appliance_list.push(itemList.item[i]); 163 appliance_list.push(itemList.item[i]);
220 } 164 }
221 } 165 }
222 } 166 }
223 } 167 }
224 -
225 //api 168 //api
226 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[1]}&where=${gu_select_encode}`; 169 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[1]}&where=${gu_select_encode}`;
227 //let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EC%83%9D%ED%99%9C%EC%B2%B4%EC%9C%A1%EA%B4%80&where=${gu_select_encode}`; 170 //let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EC%83%9D%ED%99%9C%EC%B2%B4%EC%9C%A1%EA%B4%80&where=${gu_select_encode}`;
228 - request(pet_url, function(err, response, body){ 171 + request(pet_url, function (err, response, body) {
229 - if(err) { 172 + if (err) {
230 console.log(`err => ${err}`) 173 console.log(`err => ${err}`)
231 } 174 }
232 else { 175 else {
233 - if(res.statusCode == 200) { 176 + if (res.statusCode == 200) {
234 - 177 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
235 - var result = convert.xml2json(body, {compact: true, spaces: 4});
236 var petJson = JSON.parse(result) 178 var petJson = JSON.parse(result)
237 -
238 var itemList = petJson.response.body.items; 179 var itemList = petJson.response.body.items;
239 var numRows = petJson.response.body.totalCount._text; //개수 180 var numRows = petJson.response.body.totalCount._text; //개수
240 - 181 + if (numRows == 1) {
241 - if (numRows == 1){
242 appliance_list.push(itemList.item); 182 appliance_list.push(itemList.item);
243 } 183 }
244 - else if (numRows == 0){} 184 + else if (numRows == 0) { }
245 else { 185 else {
246 - for (i=0; i<numRows; i++){ 186 + for (i = 0; i < numRows; i++) {
247 appliance_list.push(itemList.item[i]); 187 appliance_list.push(itemList.item[i]);
248 } 188 }
249 } 189 }
250 } 190 }
251 } 191 }
252 -
253 //api 192 //api
254 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[2]}&where=${gu_select_encode}`; 193 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[2]}&where=${gu_select_encode}`;
255 - request(pet_url, function(err, response, body){ 194 + request(pet_url, function (err, response, body) {
256 - if(err) { 195 + if (err) {
257 console.log(`err => ${err}`) 196 console.log(`err => ${err}`)
258 } 197 }
259 else { 198 else {
260 - if(res.statusCode == 200) { 199 + if (res.statusCode == 200) {
261 - var result = convert.xml2json(body, {compact: true, spaces: 4}); 200 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
262 var petJson = JSON.parse(result) 201 var petJson = JSON.parse(result)
263 -
264 var itemList = petJson.response.body.items; 202 var itemList = petJson.response.body.items;
265 var numRows = petJson.response.body.totalCount._text; //개수 203 var numRows = petJson.response.body.totalCount._text; //개수
266 - 204 + if (numRows == 1) {
267 - if (numRows == 1){
268 appliance_list.push(itemList.item); 205 appliance_list.push(itemList.item);
269 } 206 }
270 - else if (numRows == 0){} 207 + else if (numRows == 0) { }
271 else { 208 else {
272 - for (i=0; i<numRows; i++){ 209 + for (i = 0; i < numRows; i++) {
273 appliance_list.push(itemList.item[i]); 210 appliance_list.push(itemList.item[i]);
274 } 211 }
275 } 212 }
276 } 213 }
277 } 214 }
278 -
279 //api 215 //api
280 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[3]}&where=${gu_select_encode}`; 216 let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode[3]}&where=${gu_select_encode}`;
281 - request(pet_url, function(err, response, body){ 217 + request(pet_url, function (err, response, body) {
282 - if(err) { 218 + if (err) {
283 console.log(`err => ${err}`) 219 console.log(`err => ${err}`)
284 } 220 }
285 else { 221 else {
286 - if(res.statusCode == 200) { 222 + if (res.statusCode == 200) {
287 - var result = convert.xml2json(body, {compact: true, spaces: 4}); 223 + var result = convert.xml2json(body, { compact: true, spaces: 4 });
288 var petJson = JSON.parse(result) 224 var petJson = JSON.parse(result)
289 -
290 var itemList = petJson.response.body.items; 225 var itemList = petJson.response.body.items;
291 var numRows = petJson.response.body.totalCount._text; //개수 226 var numRows = petJson.response.body.totalCount._text; //개수
292 - 227 + if (numRows == 1) {
293 - if (numRows == 1){
294 appliance_list.push(itemList.item); 228 appliance_list.push(itemList.item);
295 } 229 }
296 - else if (numRows == 0){} 230 + else if (numRows == 0) { }
297 else { 231 else {
298 - for (i=0; i<numRows; i++){ 232 + for (i = 0; i < numRows; i++) {
299 appliance_list.push(itemList.item[i]); 233 appliance_list.push(itemList.item[i]);
300 } 234 }
301 } 235 }
302 236
303 //테스트용 console.log 237 //테스트용 console.log
304 - for(i=0; i<appliance_list.length; i++){ 238 + for (i = 0; i < appliance_list.length; i++) {
305 - titles = titles+appliance_list[i].title._text+'\n'; 239 + titles = titles + appliance_list[i].title._text + '\n';
306 } 240 }
307 - 241 + if (titles == '') { console.log('nothing'); }
308 - if (titles == '') {console.log('nothing');} 242 + else { console.log(titles); }
309 - else {console.log(titles); }
310 } 243 }
311 } 244 }
312 res.render('result', { category: 'park', titles: titles, appliance_list: appliance_list }); 245 res.render('result', { category: 'park', titles: titles, appliance_list: appliance_list });
...@@ -314,6 +247,5 @@ router.post('/park', function(req, res){ ...@@ -314,6 +247,5 @@ router.post('/park', function(req, res){
314 }); 247 });
315 }); 248 });
316 }); 249 });
317 - }); 250 +});
318 -
319 module.exports = router; 251 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
1 +var express = require('express');
2 +var router = express.Router();
3 +var path = require('path');
4 +router.use('/bootstrap', express.static(path.join(__dirname, "../node_modules/bootstrap/dist")));
5 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
1 +<!DOCTYPE html>
2 +<html lang="ko">
3 +
4 +<head>
5 + <meta charset="UTF-8">
6 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap.min.css' />
8 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap-grid.min.css' />
9 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap-reboot.min.css' />
10 + <link rel='stylesheet' href='/css/category.css'>
11 + <link rel="preconnect" href="https://fonts.gstatic.com">
12 + <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300&display=swap" rel="stylesheet">
13 + <title>📝 진단 검사</title>
14 +</head>
15 +
16 +<body>
17 + <%- include('components/locationJumbotron') -%>
18 + <%- include('components/category') -%>
19 +</body>
20 +
21 +</html>
...\ No newline at end of file ...\ No newline at end of file
1 <ul class="nav nav-pills nav-stacked"> 1 <ul class="nav nav-pills nav-stacked">
2 - <li role="presentation" class="active"><a href="#">동물 병원</a></li> 2 + <li role="presentation"><a href="">사용법</a></li>
3 - <li role="presentation"><a href="#">동물 약국</a></li> 3 + <li role="presentation" class="active"><a href="/category/hospital">🏥동물 병원🏥</a></li>
4 - <li role="presentation"><a href="#">공원</a></li> 4 + <li role="presentation"><a href="/category/medicine">💊동물 약국💊</a></li>
5 - <li role="presentation"><a href="#">동물 보호 시설</a></li> 5 + <li role="presentation"><a href="/category/appliance">🩺동물의료기기 판매🩺</a></li>
6 + <li role="presentation"><a href="/category/park">🌳체육시설🌳</a></li>
6 </ul> 7 </ul>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
2 <html> 2 <html>
3 3
4 <head> 4 <head>
5 - <title>Animal Info</title> 5 + <title>🐶 Animal Info</title>
6 <!-- 합쳐지고 최소화된 최신 CSS --> 6 <!-- 합쳐지고 최소화된 최신 CSS -->
7 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> 7 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
8 -
9 <!-- 부가적인 테마 --> 8 <!-- 부가적인 테마 -->
10 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> 9 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
11 -
12 <!-- 합쳐지고 최소화된 최신 자바스크립트 --> 10 <!-- 합쳐지고 최소화된 최신 자바스크립트 -->
13 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> 11 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
14 -
15 <style> 12 <style>
16 html { 13 html {
17 min-height: 100%; 14 min-height: 100%;
...@@ -65,43 +62,58 @@ ...@@ -65,43 +62,58 @@
65 font-size: xx-large; 62 font-size: xx-large;
66 } 63 }
67 </style> 64 </style>
68 -
69 <script> 65 <script>
70 function sm() { 66 function sm() {
71 document.getElementById("location").submit(); 67 document.getElementById("location").submit();
72 } 68 }
73 </script> 69 </script>
74 -
75 -
76 </head> 70 </head>
77 71
78 <body> 72 <body>
79 -
80 <header id="header"> 73 <header id="header">
81 <%- include("components/header") -%> 74 <%- include("components/header") -%>
82 </header> 75 </header>
83 -
84 <div class="content"> 76 <div class="content">
85 <div class="nav"> 77 <div class="nav">
86 <%- include("components/navigation") -%> 78 <%- include("components/navigation") -%>
87 </div> 79 </div>
88 -
89 <div class="jumbotron"> 80 <div class="jumbotron">
90 <h2>서울시 동물 병원 검색</h2> 81 <h2>서울시 동물 병원 검색</h2>
91 <p> 82 <p>
92 지역 선택 83 지역 선택
93 </p> 84 </p>
94 - <form action="/category/park" method="post" name="location" id="location"> 85 + <form action="/category" method="POST" name="location" id="location">
95 <select onchange="sm()" name="user_gu" id="user_gu_select"> 86 <select onchange="sm()" name="user_gu" id="user_gu_select">
96 <option value='' selected="true" disabled="true">--Please choose an option--</option> 87 <option value='' selected="true" disabled="true">--Please choose an option--</option>
97 - <option value='금천구'>금천구</option>
98 <option value='강남구'>강남구</option> 88 <option value='강남구'>강남구</option>
89 + <option value='강동구'>강동구</option>
90 + <option value='강북구'>강북구</option>
91 + <option value='강서구'>강서구</option>
92 + <option value='관악구'>관악구</option>
93 + <option value='광진구'>광진구</option>
94 + <option value='구로구'>구로구</option>
95 + <option value='금천구'>금천구</option>
96 + <option value='노원구'>노원구</option>
97 + <option value='도봉구'>도봉구</option>
98 + <option value='동대문구'>동대문구</option>
99 + <option value='동작구'>동작구</option>
100 + <option value='마포구'>마포구</option>
101 + <option value='서대문구'>서대문구</option>
102 + <option value='서초구'>서초구</option>
103 + <option value='성동구'>성동구</option>
104 + <option value='성북구'>성북구</option>
105 + <option value='송파구'>송파구</option>
106 + <option value='양천구'>양천구</option>
107 + <option value='영등포구'>영등포구</option>
108 + <option value='용산구'>용산구</option>
109 + <option value='은평구'>은평구</option>
110 + <option value='종로구'>종로구</option>
111 + <option value='중구'>중구</option>
112 + <option value='중랑구'>중랑구</option>
99 </select> 113 </select>
100 </form> 114 </form>
101 </div> 115 </div>
102 </div> 116 </div>
103 -
104 -
105 <footer id="footer"> 117 <footer id="footer">
106 <%- include("components/footer") -%> 118 <%- include("components/footer") -%>
107 </footer> 119 </footer>
......
1 +<!DOCTYPE html>
2 +<html lang="ko">
3 +
4 +<head>
5 + <meta charset="UTF-8">
6 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap.min.css' />
8 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap-grid.min.css' />
9 + <link rel='stylesheet' href='/vendors/bootstrap/css/bootstrap-reboot.min.css' />
10 + <link rel="preconnect" href="https://fonts.gstatic.com">
11 + <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300&display=swap" rel="stylesheet">
12 + <title>📝 결과</title>
13 +</head>
14 +
1 <body> 15 <body>
2 <%- include(`results/${category}`) -%> 16 <%- include(`results/${category}`) -%>
3 </body> 17 </body>
18 +
19 +</html>
...\ No newline at end of file ...\ No newline at end of file
......
1 -it's appliance page
...\ No newline at end of file ...\ No newline at end of file
1 +<h4>🩺 동물의료기기 판매 및 임대업체 현황</h4>
2 +<table class="table">
3 + <thead class="thead-dark">
4 + <tr>
5 + <th>이름</th>
6 + <th>도로명주소</th>
7 + </tr>
8 + </thead>
9 + <tbody>
10 + <%for (var i=0; i <appliance_list.length; i++){%>
11 + <tr>
12 + <td>
13 + <%=appliance_list[i].title._text%>
14 + </td>
15 + <td>
16 + <%=appliance_list[i].venue._text%>
17 + </td>
18 + </tr>
19 + <%}%>
20 +
21 + </tbody>
22 +</table>
23 +<p class="sum">총 개수 :
24 + <%=appliance_list.length%>
25 +</p>
...\ No newline at end of file ...\ No newline at end of file
......
1 -it's hospital page
...\ No newline at end of file ...\ No newline at end of file
1 +<h4>🏥 동물병원 현황</h4>
2 +<table class="table">
3 + <thead class="thead-dark">
4 + <tr>
5 + <th>동물병원명</th>
6 + <th>도로명주소</th>
7 + </tr>
8 + </thead>
9 + <tbody>
10 + <%for (var i=0; i <hospital_list.length; i++){%>
11 + <tr>
12 + <td>
13 + <%=hospital_list[i].title._text%>
14 + </td>
15 + <td>
16 + <%=hospital_list[i].venue._text%>
17 + </td>
18 + </tr>
19 + <%}%>
20 +
21 + </tbody>
22 +</table>
23 +<p class="sum">총 동물병원 개수 :
24 + <%-hospital_list.length%>
25 +</p>
...\ No newline at end of file ...\ No newline at end of file
......
1 -it's medicine page
...\ No newline at end of file ...\ No newline at end of file
1 +<h4> 💊동물약국 현황</h4>
2 +<table class="table">
3 + <thead class="thead-dark">
4 + <tr>
5 + <th>동물약국명</th>
6 + <th>도로명주소</th>
7 + </tr>
8 + </thead>
9 + <tbody>
10 + <%for (var i=0; i <category_list.length; i++){%>
11 + <tr>
12 + <td>
13 + <%=category_list[i].title._text%>
14 + </td>
15 + <td>
16 + <%=category_list[i].venue._text%>
17 + </td>
18 + </tr>
19 + <%}%>
20 +
21 + </tbody>
22 +</table>
23 +<p class="sum">총 동물약국 개수 :
24 + <%-category_list.length%>
25 +</p>
...\ No newline at end of file ...\ No newline at end of file
......
1 -it's park page
...\ No newline at end of file ...\ No newline at end of file
1 +<h4>🌳 도시공원 현황</h4>
2 +<table class="table">
3 + <thead class="thead-dark">
4 + <tr>
5 + <th>도시공원명</th>
6 + <th>도로명주소</th>
7 + </tr>
8 + </thead>
9 + <tbody>
10 + <%for (var i=0; i <appliance_list.length; i++){%>
11 + <tr>
12 + <td>
13 + <%=appliance_list[i].title._text%>
14 + </td>
15 + <td>
16 + <%=appliance_list[i].venue._text%>
17 + </td>
18 + </tr>
19 + <%}%>
20 +
21 + </tbody>
22 +</table>
23 +<p class="sum">총 도시공원 개수 :
24 + <%=appliance_list.length%>
25 +</p>
...\ No newline at end of file ...\ No newline at end of file
......