-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (33 loc) · 874 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
31
32
33
34
35
36
37
38
39
40
41
42
require('dotenv').config();
const express = require('express')
const hbs = require('hbs');
const app = express()
const port = process.env.PORT;
// Handlebars
app.set('view engine','hbs');
hbs.registerPartials( __dirname + '/views/partials');
//Servir contenido estatico
app.use(express.static('public'));
// Rutas de la pagina
app.get('/', (req, res) => {
res.render( 'home',{
nombre:'Facu Bzn',
titulo:'Curso de Node js'
});
});
app.get('/generic', (req, res) => {
res.render( 'generic');
});
app.get('/elements', (req, res) => {
res.render('elements');
});
app.get('*', (req, res) => {
res.render('404');
});
/* app.get('*', (req, res) => {
res.sendFile(__dirname + '/public/index.html');
}); */
/* app.listen(8080) */
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})