박지환

Update server.js to prevent limiting daily traffic

...@@ -23,6 +23,7 @@ var text = ""; ...@@ -23,6 +23,7 @@ var text = "";
23 var dateName = []; 23 var dateName = [];
24 var locdate = []; 24 var locdate = [];
25 var tempArr = []; 25 var tempArr = [];
26 +var todayDate = "";
26 27
27 // To run EJS engine 28 // To run EJS engine
28 app.set("views", __dirname + "/views"); 29 app.set("views", __dirname + "/views");
...@@ -36,7 +37,6 @@ function getTodayDate() { ...@@ -36,7 +37,6 @@ function getTodayDate() {
36 var month = ("0" + (today.getMonth() + 1)).slice(-2); 37 var month = ("0" + (today.getMonth() + 1)).slice(-2);
37 var day = ("0" + today.getDate()).slice(-2); 38 var day = ("0" + today.getDate()).slice(-2);
38 var dateString = year + "-" + month + "-" + day; 39 var dateString = year + "-" + month + "-" + day;
39 -
40 //return "2022-12-25"; // 테스트용 날짜를 입력하세요. *** 테스트가 끝나면 주석처리하고 커밋해주세요. *** ex) 2022-09-12, 2022-09-15, 2022-10-04 40 //return "2022-12-25"; // 테스트용 날짜를 입력하세요. *** 테스트가 끝나면 주석처리하고 커밋해주세요. *** ex) 2022-09-12, 2022-09-15, 2022-10-04
41 return dateString; 41 return dateString;
42 } 42 }
...@@ -165,14 +165,19 @@ function getData() { ...@@ -165,14 +165,19 @@ function getData() {
165 165
166 // To initialize datas when calling webpage 166 // To initialize datas when calling webpage
167 function init() { 167 function init() {
168 - // Intialize Year, Month 168 + // To get now date
169 - var date = getTodayDate().split("-"); 169 + var tempDate = getTodayDate();
170 - year = date[0]; 170 + if (tempDate != todayDate) {
171 - month = date[1]; 171 + // Intialize Year, Month
172 - operation = "getRestDeInfo"; 172 + todayDate = tempDate;
173 - changeParams(year, month, operation); 173 + var date = todayDate.split("-");
174 - // Get data from holiday api 174 + year = date[0];
175 - getData(); 175 + month = date[1];
176 + operation = "getRestDeInfo";
177 + changeParams(year, month, operation);
178 + // Get data from holiday api
179 + getData();
180 + }
176 } 181 }
177 182
178 // Get request for web service 183 // Get request for web service
......