forked from AgoraUS1516/G10
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
37 lines (30 loc) · 987 Bytes
/
server.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
31
32
33
34
35
36
37
// Imports
const express = require('express'),
app = express(),
router = express.Router(),
port = 8080,
recuento = require('./recuentoController.js') //privadoController llama a nuestra base de datos (solo para pruebas),
//recuentoController llama a la api de recuento verdadera
// Public folders
app.use(express.static(__dirname + '/views'))
app.use(express.static(__dirname + '/src'))
app.use('/api', recuento) //se llama al controlador siempre que se recibe una petición a la API
// App's routes
router.get('/', function(req, res) {
res.sendFile('index.html')
})
router.get('/*', function(req, res) {
res.sendFile(__dirname+'/views/index.html')
})
app.use(router)
// Starting node server
app.listen(port, () => {
console.log("Magic happens on port " + port)
})
// Make node.js not exit on error
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
setTimeout(function () {
console.log('This will still run.');
}, 500);