Commit 828f919706f8729f86c4cc81199075a4db0ecec7

Authored by Paul Wallace
1 parent 37a149e698
Exists in master

Add routes for crime data api call

Showing 3 changed files with 40 additions and 1 deletions Inline Diff

var express = require('express'); 1 1 var express = require('express');
2 var crime = require('./routes/crime');
2 3
4
var app = express(); 3 5 var app = express();
4 6
app.set('port', (process.env.PORT || 5000)); 5 7 app.set('port', (process.env.PORT || 5000));
6 8
app.use(express.static(__dirname + '/public')); 7 9 app.use(express.static(__dirname + '../public'));
8 10
// views is directory for all template files 9 11 // views is directory for all template files
app.set('views', __dirname + '/views'); 10 12 app.set('views', __dirname + '/views');
app.set('view engine', 'ejs'); 11 13 app.set('view engine', 'ejs');
12 14
app.get('/', function(request, response) { 13 15 app.get('/', function(request, response) {
response.render('pages/index'); 14 16 response.render('pages/index');
}); 15 17 });
16 18
app.get('/landing', function(request, response) { 17 19 app.get('/landing', function(request, response) {
response.render('pages/landing'); 18 20 response.render('pages/landing');
}); 19 21 });
routes/crime.js View file @ 828f919
File was created 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")
views/pages/tempcrime.ejs View file @ 828f919
File was created 1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <% include ../partials/header %>
5 </head>
6
7 <body>
8 <%= body %>
9 </body>