Commit 084bd69ab63d69a13c259130916d511d809b05cd

Authored by Paul Wallace
1 parent 671e58c586
Exists in master

Add routes for crime stuff

Showing 3 changed files with 38 additions and 0 deletions Side-by-side Diff

1 1 var express = require('express');
2 2  
3 3 var app = express();
  4 +var app = require('/crime');
4 5  
5 6 app.set('port', (process.env.PORT || 5000));
6 7  
... ... @@ -17,6 +18,8 @@
17 18 app.get('/landing', function(request, response) {
18 19 response.render('pages/landing');
19 20 });
  21 +
  22 +app.get('/crime', crime.index);
20 23  
21 24 app.listen(app.get('port'), function() {
22 25 console.log('Node app is running on port', app.get('port'));
routes/crime.js View file @ 084bd69
  1 +var unirest = require('unirest');
  2 +
  3 +exports.view = function(req, res){
  4 +
  5 + unirest.get("https://yourmapper2.p.mashape.com/datasetlist?format=json&maxlat=40&maxlon=-70&minlat=30&minlon=-90&num=5&sort=location")
  6 + .header("X-Mashape-Key", "gj4g6D3zxKmshys7yyf9KNbuywOxp1ueazFjsn6n2fK4sccIGA")
  7 + .header("Accept", "application/json")
  8 + .end(function (result) {
  9 + // console.log(result.status, result.headers, result.body);
  10 +
  11 + });
  12 +
  13 +
  14 +
  15 + // These code snippets use an open-source library. http://unirest.io/nodejs
  16 + unirest.get("https://crimescore.p.mashape.com/crimescore?f=json&id=174&lat=38.08809&lon=-85.679626")
  17 + .header("X-Mashape-Key", "gj4g6D3zxKmshys7yyf9KNbuywOxp1ueazFjsn6n2fK4sccIGA")
  18 + .header("Accept", "application/json")
  19 + .end(function (result) {
  20 + res.render('pages/tempcrime', result);
  21 + });
  22 +
  23 +
  24 +};
views/pages/tempcrime.ejs View file @ 084bd69
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 + <head>
  4 + <% include ../partials/header %>
  5 + </head>
  6 +
  7 + <body>
  8 + <%= body %>
  9 + </body>
  10 +
  11 + </html>