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 Inline Diff

var express = require('express'); 1 1 var express = require('express');
2 2
var app = express(); 3 3 var app = express();
4 var app = require('/crime');
4 5
app.set('port', (process.env.PORT || 5000)); 5 6 app.set('port', (process.env.PORT || 5000));
6 7
app.use(express.static(__dirname + '/public')); 7 8 app.use(express.static(__dirname + '/public'));
8 9
// views is directory for all template files 9 10 // views is directory for all template files
app.set('views', __dirname + '/views'); 10 11 app.set('views', __dirname + '/views');
app.set('view engine', 'ejs'); 11 12 app.set('view engine', 'ejs');
12 13
app.get('/', function(request, response) { 13 14 app.get('/', function(request, response) {
response.render('pages/index'); 14 15 response.render('pages/index');
}); 15 16 });
16 17
app.get('/landing', function(request, response) { 17 18 app.get('/landing', function(request, response) {
response.render('pages/landing'); 18 19 response.render('pages/landing');
routes/crime.js View file @ 084bd69
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 @ 084bd69
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>