forked from 00f2ff/donationviz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (21 loc) · 888 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var express = require("express");
var morgan = require('morgan');
var dbRoutes = require('./routes/dbRoutes');
var app = express();
// logging
app.use(morgan('dev'));
// Set the views directory
app.set('views', __dirname + '/views');
// Define the view (templating) engine
app.set('view engine', 'ejs');
// load static pages
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res) { res.render('index', {'header': 'Senators by State'}); });
// My assumption is that companies don't have the same name since I don't have a good identifier
// Using senator names for simplicity
app.get('/senator/:name', dbRoutes.loadSenator);
app.get('/organization/:name', dbRoutes.loadOrganization);
// Catch any routes not already handed with an error message
app.use(dbRoutes.errorMessage);
app.listen(50000);
console.log("Server listening at http://localhost:50000/");