-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (36 loc) · 995 Bytes
/
app.js
File metadata and controls
44 lines (36 loc) · 995 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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');
// Middleware: Servir contenido estático
app.use(express.static('public'));
app.get('/', (req, res) => {
res.render('home', {
nombre: 'Oscar Cornejo',
titulo: 'WebServer',
});
});
app.get('/generic', (req, res) => {
// res.sendFile(__dirname + '/public/generic.html');
res.render('generic', {
nombre: 'Oscar Cornejo',
titulo: 'WebServer',
});
});
app.get('/elements', (req, res) => {
// res.sendFile(__dirname + '/public/elements.html');
res.render('elements', {
nombre: 'Oscar Cornejo',
titulo: 'WebServer',
});
});
// app.get('*', (req, res) => {
// res.sendFile(__dirname + '/public/404.html');
// });
app.listen(port, () => {
console.log(`Corriendo en: http://localhost:${port} 🚀`);
});