-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (50 loc) · 1.54 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const express = require('express');
const app = express();
//const port = 3000;
require('dotenv').config()
//Conexion a Base de datos
const mongoose = require('mongoose');
const user = 'pruebas_memo';
const password = 'ijzoT9QEsVlOlmrD';
const dbname = 'veterinaria';
const uri = `mongodb+srv://${user}:${password}@cluster0.emcqd.gcp.mongodb.net/${dbname}?retryWrites=true&w=majority`;
mongoose.connect(uri,
{useNewUrlParser: true, useUnifiedTopology: true}
)
.then(()=>console.log('Base de datos conectada'))
.catch(e => console.log(e));
// Motor de plantillas
app.set('view engine', 'ejs');
app.set('views', __dirname+'/views');
app.use(express.static(__dirname + "/public"));
//Rutas Web
app.use('/', require('./router/RutasWeb'));
app.use('/mascotas', require('./router/Mascotas'));
app.use((req,res,next)=>{
//res.status(404).sendFile(__dirname + '/public/404.html');
res.status(404).render('404', {
titulo: '404',
msj: 'Página no encontrada'
});
});
/*
app.listen(port, ()=>{
console.log('Servidor a su servicio en el puerto', port);
})
*/
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Our app is running on port ${ PORT }`);
});
/*SERVIDOR NODE JS
const http = require('http');
const port = 3000;//const port = process.env.PORT;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
res.end("<h1>Nueva version de la pagina web.</h1>");
});
server.listen(port, () => {
console.log(`El servidor esta corriendo - Port: ${port}`);
});
*/