-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
28 lines (23 loc) · 891 Bytes
/
index.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
/* eslint-disable no-unused-vars */
var fs = require('fs')
var path = require('path');
var express = require('express');
var app = express();
var mongoClient = require('mongodb').MongoClient;
var mongoUrl = 'mongodb://localhost:27017/';
var mongoDb = 'ballparkTracker';
var mongoCollection = 'parks';
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// app.use(express.json());
// main app page
app.get('/', (req, res) => res.render('index', { AZURE_MAPS_KEY: '[YOUR KEY HERE]' }));
// return a json list of ballparks
app.get('/api/parks', (req, res) => {
var jsonFile = fs.readFileSync('public/data/location.geojson', 'utf8');
res.send(jsonFile);
});
// Configuring static assets (css/js)
app.use(express.static('public'))
app.listen(3000);
if (!fs.existsSync(`${process.env.HOME}/.nodemon-running`)) console.log('Running at http://localhost:3000');