Showing
9 changed files
with
329 additions
and
0 deletions
.vscode/launch.json
0 → 100644
| 1 | +{ | ||
| 2 | + // Use IntelliSense to learn about possible attributes. | ||
| 3 | + // Hover to view descriptions of existing attributes. | ||
| 4 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| 5 | + "version": "0.2.0", | ||
| 6 | + "configurations": [ | ||
| 7 | + { | ||
| 8 | + "type": "node", | ||
| 9 | + "request": "launch", | ||
| 10 | + "name": "Launch Program", | ||
| 11 | + "program": "${workspaceFolder}\\nodeJs\\app.js" | ||
| 12 | + } | ||
| 13 | + ] | ||
| 14 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
nodeJs/.gitignore
0 → 100644
nodeJs/BMDOHYEON_ttf.ttf
0 → 100644
No preview for this file type
nodeJs/app.js
0 → 100644
| 1 | +var express = require('express'); | ||
| 2 | +var path = require('path'); | ||
| 3 | +var bodyParser = require('body-parser'); | ||
| 4 | +var server_router = require('./router/server') | ||
| 5 | +var default_router = require('./router/default') | ||
| 6 | + | ||
| 7 | +var app = express(); | ||
| 8 | +var nPort = 3000; | ||
| 9 | + | ||
| 10 | +app.use('/', default_router) | ||
| 11 | + | ||
| 12 | +app.engine('html', require('ejs').renderFile); | ||
| 13 | +app.use(express.static(path.join(__dirname, 'public'))); | ||
| 14 | +app.set('views', path.join(__dirname, 'public/view')); | ||
| 15 | + | ||
| 16 | +app.use(function(err, req, res, next) { | ||
| 17 | + console.log("[APP]:ERR > " + err); | ||
| 18 | +}) | ||
| 19 | +app.listen(nPort, function () { | ||
| 20 | + console.log('app listening on port ' + nPort); | ||
| 21 | +}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
nodeJs/package.json
0 → 100644
| 1 | +{ | ||
| 2 | + "name": "goodsdetect", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | + "description": "web page to find items in pictures ", | ||
| 5 | + "main": "index.js", | ||
| 6 | + "scripts": { | ||
| 7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
| 8 | + }, | ||
| 9 | + "repository": { | ||
| 10 | + "type": "git", | ||
| 11 | + "url": "git+https://github.com/skgndi12/GoodsDetect_using_nodejs.git" | ||
| 12 | +}, | ||
| 13 | +"author": "Kim Sung Won, Kim Ji Ye, Kim Hye Rim", | ||
| 14 | + "license": "ISC", | ||
| 15 | + "dependencies": { | ||
| 16 | + "body-parser": "^1.18.3", | ||
| 17 | + "ejs": "^2.6.1", | ||
| 18 | + "express": "^4.16.4", | ||
| 19 | + "path": "^0.12.7", | ||
| 20 | + "request": "^2.88.0", | ||
| 21 | + "ws": "^6.1.2" | ||
| 22 | + } | ||
| 23 | +} |
nodeJs/public/view/index.html
0 → 100644
| 1 | +<!doctype html> | ||
| 2 | +<html lang="en"> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="UTF-8"> | ||
| 5 | + <meta http-equiv = "X-UA-Compatible" content = "IE=edge"> | ||
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"> | ||
| 7 | + <meta name="Generator" content="EditPlus®"> | ||
| 8 | + <meta name="Author" content=""> | ||
| 9 | + <meta name="Keywords" content=""> | ||
| 10 | + <meta name="Description" content=""> | ||
| 11 | + | ||
| 12 | + <title>영통구 음식점 추천</title> | ||
| 13 | + <script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=6u4gqwh2ta"></script> | ||
| 14 | + <script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=6u4gqwh2ta&submodules=geocoder"></script> | ||
| 15 | + </head> | ||
| 16 | + <body> | ||
| 17 | + <div id = "title"> | ||
| 18 | + <br> | ||
| 19 | + <h2><center>영통구 음식점 추천 페이지<br><br><br> | ||
| 20 | + </center></h2> | ||
| 21 | + | ||
| 22 | + </div> | ||
| 23 | + <div class = "left"> | ||
| 24 | + <br>선택하세요! | ||
| 25 | + <br> | ||
| 26 | + <div id = "left_left" class = "left"> | ||
| 27 | + <br> | ||
| 28 | + <select name = "dong", id = "dong"> | ||
| 29 | + <option value = "">동 선택</option> | ||
| 30 | + <option value = "영통동">영통동</option> | ||
| 31 | + <option value = "매탄동">매탄동</option> | ||
| 32 | + <option value = "원천동">원천동</option> | ||
| 33 | + </select> | ||
| 34 | + <br> | ||
| 35 | + </div> | ||
| 36 | + <div id = "left_right" class = "left"> | ||
| 37 | + <br> | ||
| 38 | + <select name = "food", id = "food"> | ||
| 39 | + <option value = "">음식 종류 선택</option> | ||
| 40 | + <option value = "한식">한식</option> | ||
| 41 | + <option value = "일식">일식</option> | ||
| 42 | + <option value = "중식">중식</option> | ||
| 43 | + <option value = "양식">양식</option> | ||
| 44 | + </select> | ||
| 45 | + <br> | ||
| 46 | + </div> | ||
| 47 | + <div id = "left_bottom" class = "left"> | ||
| 48 | + | ||
| 49 | + <button onclick = "onClick()">지도에서 확인하기!</button> | ||
| 50 | + <br> | ||
| 51 | + <br> | ||
| 52 | + <textarea id = "textcontents" cols = "60" rows = "10"style="border:7px solid rgb(191, 191, 191);"></textarea> | ||
| 53 | + </div> | ||
| 54 | + </div> | ||
| 55 | + | ||
| 56 | + <div id = "right" style = "width:600px;height:430px;border:7px solid rgb(191, 191, 191);float:right"> | ||
| 57 | + </div> | ||
| 58 | + | ||
| 59 | + <!--<script type = "text/javascript"> | ||
| 60 | + var mapOptions = { | ||
| 61 | + center: new naver.maps.LatLng(37.250899, 127.072985), | ||
| 62 | + zoom : 10 | ||
| 63 | + }; | ||
| 64 | + var map = new naver.maps.Map('right', mapOptions); | ||
| 65 | + </script>--> | ||
| 66 | + <script type = "text/javascript"> | ||
| 67 | + function onClick(){ | ||
| 68 | + var target_dong = document.getElementById("dong"); | ||
| 69 | + var target_food = document.getElementById("food"); | ||
| 70 | + if(target_dong.options[target_dong.selectedIndex].value == "" || target_food.options[target_food.selectedIndex].value == "") | ||
| 71 | + { | ||
| 72 | + alert('선택하세요.'); | ||
| 73 | + } | ||
| 74 | + else | ||
| 75 | + { | ||
| 76 | + var message = target_dong.options[target_dong.selectedIndex].value + ' ' + target_food.options[target_food.selectedIndex].value; | ||
| 77 | + alert('전달 메세지 : ' + message); | ||
| 78 | + | ||
| 79 | + // 웹소켓 전역 객체 생성 | ||
| 80 | + var ws = new WebSocket("ws://localhost:9000"); | ||
| 81 | + | ||
| 82 | + // 연결이 수립되면 서버에 메시지를 전송한다 | ||
| 83 | + ws.onopen = function(event) { | ||
| 84 | + ws.send(message); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + // 서버로 부터 메시지를 수신한다 | ||
| 88 | + ws.onmessage = function(event) { | ||
| 89 | + ws.close(); | ||
| 90 | + console.log("Server message: ", event.data); | ||
| 91 | + var result = JSON.parse(event.data); | ||
| 92 | + // result.title, mapx, mapy | ||
| 93 | + | ||
| 94 | + var mapOptions = { | ||
| 95 | + center: new naver.maps.LatLng(37.250899, 127.072985), | ||
| 96 | + zoom : 10 | ||
| 97 | + }; | ||
| 98 | + var map = new naver.maps.Map('right', mapOptions); | ||
| 99 | + | ||
| 100 | + var marker = new Array(5); | ||
| 101 | + var textString = ''; | ||
| 102 | + for(var i = 0; i < result.length; i++) | ||
| 103 | + { | ||
| 104 | + var tm128 = new naver.maps.Point(result[i].mapx, result[i].mapy); | ||
| 105 | + var naverpoint = naver.maps.TransCoord.fromTM128ToNaver(tm128); | ||
| 106 | + var latlng = naver.maps.TransCoord.fromNaverToLatLng(naverpoint); | ||
| 107 | + marker[i] = new naver.maps.Marker({ | ||
| 108 | + position : new naver.maps.LatLng(latlng), | ||
| 109 | + map : map | ||
| 110 | + }); | ||
| 111 | + | ||
| 112 | + textString = textString + '이름 : ' + result[i].title + '\n주소 : ' + result[i].address + '\nTEL) : ' + result[i].telephone + '\n'; | ||
| 113 | + | ||
| 114 | + var contentString = [ | ||
| 115 | + '<div class = iw>', | ||
| 116 | + ' <h3><center>' + result[i].title + '</center></h3>', | ||
| 117 | + ' <p><font size = "2"> 주소 : ' + result[i].address + '</br>', | ||
| 118 | + ' TEL) : ' + result[i].telephone + '</font></p>', | ||
| 119 | + '</div>' | ||
| 120 | + ].join(''); | ||
| 121 | + | ||
| 122 | + var infowindow = new naver.maps.InfoWindow({ | ||
| 123 | + content : contentString, | ||
| 124 | + position : new naver.maps.LatLng(latlng) | ||
| 125 | + }); | ||
| 126 | + | ||
| 127 | + naver.maps.Event.addListener(marker[i], "click", function(e) { | ||
| 128 | + if(infowindow.getMap()) { | ||
| 129 | + infowindow.close(); | ||
| 130 | + } else { | ||
| 131 | + infowindow.open(map, marker[i]); | ||
| 132 | + } | ||
| 133 | + }); | ||
| 134 | + } | ||
| 135 | + var textElement = document.getElementById('textcontents'); | ||
| 136 | + textElement.value = ''; | ||
| 137 | + textElement.value = textString; | ||
| 138 | + | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + // error event handler | ||
| 142 | + ws.onerror = function(event) { | ||
| 143 | + console.log("Server error message: ", event.data); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + }; | ||
| 147 | + </script> | ||
| 148 | + | ||
| 149 | + <style type="text/css"> | ||
| 150 | + body { | ||
| 151 | + font-family: '배달의민족 도현'; | ||
| 152 | + background-color: rgb(230, 243, 255); | ||
| 153 | + line-height: 110%; | ||
| 154 | + | ||
| 155 | + } | ||
| 156 | + button { | ||
| 157 | + width: 220px; | ||
| 158 | + font-family: '배달의민족 도현'; | ||
| 159 | + font-size:20px; | ||
| 160 | + background-color: rgb(194, 240, 194); | ||
| 161 | + box-sizing: border-box; | ||
| 162 | + border: 3px solid rgb(194, 240, 194); | ||
| 163 | + border-radius: 4px; | ||
| 164 | + padding: 15px 15px 15px 15px; | ||
| 165 | + | ||
| 166 | + } | ||
| 167 | + select { | ||
| 168 | + width: 200px; | ||
| 169 | + border: 3px solid rgb(251, 199, 205); | ||
| 170 | + border-radius: 4px; | ||
| 171 | + font-size: 20px; | ||
| 172 | + font-family: '배달의민족 도현'; | ||
| 173 | + background-color: rgb(251, 199, 205); | ||
| 174 | + background-position: 5px 2.5px; | ||
| 175 | + padding: 10px 10px 10px 10px; | ||
| 176 | + } | ||
| 177 | + div | ||
| 178 | + #title | ||
| 179 | + { | ||
| 180 | + width : 200px; | ||
| 181 | + height : 400px; | ||
| 182 | + float : left; | ||
| 183 | + text-align : center; | ||
| 184 | + border : 3px solid rgb(230, 243, 255); | ||
| 185 | + } | ||
| 186 | + .left | ||
| 187 | + { | ||
| 188 | + font-size: 20px; | ||
| 189 | + width : 600px; | ||
| 190 | + height : 430px; | ||
| 191 | + float : left; | ||
| 192 | + text-align : center; | ||
| 193 | + border : 7px solid rgb(191, 191, 191); | ||
| 194 | + } | ||
| 195 | + #left_left | ||
| 196 | + { | ||
| 197 | + width : 240px; | ||
| 198 | + height : 100px; | ||
| 199 | + float : left; | ||
| 200 | + border : 3px solid rgb(230, 243, 255); | ||
| 201 | + } | ||
| 202 | + #left_right | ||
| 203 | + { | ||
| 204 | + width : 240px; | ||
| 205 | + height : 100px; | ||
| 206 | + float : right; | ||
| 207 | + border : 3px solid rgb(230, 243, 255); | ||
| 208 | + } | ||
| 209 | + #left_bottom | ||
| 210 | + { | ||
| 211 | + width : 600px; | ||
| 212 | + height : 300px; | ||
| 213 | + float : left; | ||
| 214 | + border : 7px solid rgb(230, 243, 255); | ||
| 215 | + } | ||
| 216 | + </style> | ||
| 217 | + </body> | ||
| 218 | +</html> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
nodeJs/public/view/khu.PNG
0 → 100644
6.36 KB
nodeJs/router/default.js
0 → 100644
| 1 | +var express = require('express') | ||
| 2 | +var router = express.Router() | ||
| 3 | +var app = express(); | ||
| 4 | + | ||
| 5 | +router.get('/', function (req, res) { | ||
| 6 | + console.log('GET/ index.html'); | ||
| 7 | + res.render('index.html'); | ||
| 8 | +}); | ||
| 9 | + | ||
| 10 | +app.use(function(err, req, res, next) { | ||
| 11 | + if (err) { | ||
| 12 | + console.log(err); | ||
| 13 | + } | ||
| 14 | +}) | ||
| 15 | +module.exports = router | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
nodeJs/router/server.js
0 → 100644
| 1 | +const WebSocket = require('ws'); | ||
| 2 | +const wss = new WebSocket.Server({ port: 9000 }); | ||
| 3 | +var request = require('request'); | ||
| 4 | +var client_id = 'jffzbdZdEiV5KGFerxOR'; | ||
| 5 | +var client_secret = 'jI15Fohs8P'; | ||
| 6 | + | ||
| 7 | +var api_url = 'https://openapi.naver.com/v1/search/local.json?display=5&query='; | ||
| 8 | +var options = { | ||
| 9 | + headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret} | ||
| 10 | +}; | ||
| 11 | + | ||
| 12 | +wss.on('connection', function connection(ws) { | ||
| 13 | + ws.on('message', function incoming(message) { | ||
| 14 | + msg = encodeURI(message); | ||
| 15 | + console.log('received: %s', decodeURI(msg)); | ||
| 16 | + options.url = api_url + msg; | ||
| 17 | + | ||
| 18 | + request.get(options, function (error, response, body) { | ||
| 19 | + if (!error && response.statusCode == 200) { | ||
| 20 | + ws.send(JSON.stringify(JSON.parse(body).items.map(x => { | ||
| 21 | + return { | ||
| 22 | + title: x.title | ||
| 23 | + , mapx: x.mapx | ||
| 24 | + , mapy: x.mapy | ||
| 25 | + , address : x.address | ||
| 26 | + , telephone : x.telephone | ||
| 27 | + } | ||
| 28 | + }))) | ||
| 29 | + } else { | ||
| 30 | + console.log("d"); | ||
| 31 | + console.l | ||
| 32 | + // console.log('error = ' + response.statusCode); | ||
| 33 | + } | ||
| 34 | + }); | ||
| 35 | + }); | ||
| 36 | +}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment