-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
64 lines (51 loc) · 1.5 KB
/
server.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
64
var path = require('path');
var express = require('express');
var exhbs = require('express-handlebars')
var app = express();
var port = process.env.PORT || 3000;
var songsData = require("./json_files/songs.json")
var photosData = require("./json_files/photos.json")
var paintingsData = require("./json_files/paintings.json")
var videosData = require('./json_files/musicvids.json')
var sketchesData = require('./json_files/sketches.json');
const { dirname } = require('path');
app.engine('handlebars', exhbs.engine({
defaultLayout: "main"
}))
app.set('view engine', 'handlebars')
app.use(express.static('public'));
app.get('/', function(req, res, next){
res.status(200).render('lucca_dohr', {
songs: songsData,
sketches: sketchesData,
})
})
app.get('/about', function(req, res, next) {
res.status(200).render('about', {
photos: photosData
})
})
app.get('/paintings', function(req, res, next) {
res.status(200).render('paintings', {
paintings: paintingsData
})
})
app.get('/videos', function(req, res, next) {
res.status(200).render('videos', {
videos: videosData
})
})
app.get('/music', function(req, res, next) {
res.status(200).render('music', {
songs: songsData
})
})
app.get('/json_files/songs.json', function(req, res, next) {
res.status(200).sendFile(__dirname + '/json_files/songs.json')
})
app.get('*', function(req, res, next){
res.status(404).render('404')
})
app.listen(port, function () {
console.log("== Server is listening on port", port);
});