1 | git clone https://hub.jazz.net/git/jstart/Picture.Finder.(Node) |
1 | var Client = rest.Client; client = new Client(); if (!address && !city && !state) res.render('index.html'); // direct way client.get(url + "?address=" + address + "&city=" + city + "&stateProvince=" + state + "&country=USA&fallbackToPostal=Y& fallbackToStreet=Y&fallbackToGeographic=Y& closeMatchesOnly=Y&appId =" + appId, function(data, response){ // data in callback contains the json returned from pitney bowes if (data.httpCode != "500") { lat = data.Output.Geometry.Pos.Y; lng = data.Output.Geometry.Pos.X; instagram.media.search({ lat: lat, lng: lng, complete: function(data){ // pinch converts all unix timestamps to a friendly date pinch(data, /created_time/, function(path, key, value) { return moment(value*1000).format("MMMM Do YYYY, h:mm a"); }); res.render('index.html', {data: data, address: address, city: city, state: state}); }, // end complete });// end search }// end httpCode check else { msg = "Can't find any pictures near this address"; res.render('index.html', {msg: msg, address: address, city: city, state: state}); } }); // end PB call |
1 | <div> <ul> {{#data}} <li style="display: inline-block; padding: 25px"><a href="{{link}}"> <img src="{{#images}}{{#thumbnail}} {{url}} {{/thumbnail}}{{/images}}"></a> <br/> By: <em> {{#user}} {{username}} {{/user}}</em> <br/> {{created_time}} <br/> {{#comments}} {{count}} {{/comments}} comment(s) {{#likes}} {{count}} {{/likes}} likes. </li> {{/data}} </ul> </div> |
1 | cf login -a api.ng.bluemix.net |
1 | --- applications: #Reference http://docs.cloudfoundry.com/doc ... -apps/manifest.html - name: PictureFinder #Application Name. Unique to the user's Space memory: 256M #The maximum memory to allocate to each application instance instances: 1 #The number of instances of the application to start host: my-unique-ehostname #Hostname for app routing. Unique to domain ng.bluemix.net. Change. path: . #Path to the application to be pushed command: node app.js #The command to use to start the application services: - Geocoding-demo #the already created geocode service |
1 | cf push |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |