-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
81 lines (68 loc) · 1.8 KB
/
server.js
File metadata and controls
81 lines (68 loc) · 1.8 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const express = require('express');
const path = require('path');
const dotenv = require('dotenv');
const expressLayouts = require('express-ejs-layouts');
// Load environment variables
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
// Set view engine
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(expressLayouts);
app.set('layout', 'layouts/main');
app.set('layout extractScripts', true);
// Static files
app.use(express.static(path.join(__dirname, 'public')));
// Body parser
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Routes
app.get('/', (req, res) => {
res.render('index', {
title: 'Motz Guitars - Designové elektrické kytary',
page: 'home'
});
});
app.get('/kytary-skladem', (req, res) => {
res.render('in-stock', {
title: 'Kytary skladem | Motz Guitars',
page: 'in-stock'
});
});
app.get('/kytary-skladem/:id', (req, res) => {
// In a real application, you would fetch the guitar by ID from a database
res.render('guitar-detail', {
title: 'Detail kytary | Motz Guitars',
page: 'in-stock',
guitarId: req.params.id
});
});
app.get('/vyroba-na-zakazku', (req, res) => {
res.render('custom-order', {
title: 'Výroba na zakázku | Motz Guitars',
page: 'custom-order'
});
});
app.get('/galerie', (req, res) => {
res.render('gallery', {
title: 'Galerie | Motz Guitars',
page: 'gallery'
});
});
app.get('/o-znacce', (req, res) => {
res.render('about', {
title: 'O značce | Motz Guitars',
page: 'about'
});
});
app.get('/kontakt', (req, res) => {
res.render('contact', {
title: 'Kontakt | Motz Guitars',
page: 'contact'
});
});
// Start server
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});