-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (23 loc) · 812 Bytes
/
app.js
File metadata and controls
30 lines (23 loc) · 812 Bytes
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
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const Router = require('./router/main.router');
//para capturar los datos del formulario y no tener errores
app.use(express.urlencoded({extended:false}));
app.use(express.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
//Setear el directorio publico
app.use('/', express.static('public'));
app.use('/', express.static(__dirname + 'public'));
console.log(__dirname);
//Establecer el motor de plantillas
app.set('view engine', 'ejs');
//Estableciendo las rutas
app.use('/', Router);
app.use('*', (req,res)=>{
res.status(404).render('404');
});
app.listen('3000', (req, res)=>{
console.log('Server Running on Port ' + '3000');
})