forked from alikillen/Libro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (32 loc) · 1.21 KB
/
app.js
File metadata and controls
45 lines (32 loc) · 1.21 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
const express = require("express")
const expressSession = require('express-session')
const port = 3000
const app = express()
// const cors = require("cors")
// const bodyParser = require("body-parser")
// const postRouter = require("./routes/posts_routes")
const handlebars = require('express-handlebars');
app.set('view engine', 'handlebars');
app.engine('handlebars', handlebars({defaultLayout: 'main'}));
//Sets handlebars configurations (we will go through them later on)
app.engine('handlebars', handlebars({
layoutsDir: __dirname + '/views/layouts',
}));
//Serves static files (we need it to import a css file)
app.use(express.static('public'))
app.get('/', (req, res) => {
//Serves the body of the page aka "main.handlebars" to the container //aka "index.handlebars"
res.render('main', {layout : 'index'});
});
// const fs = require("fs")
// // parse application/x-www-form-urlencoded
// app.use(bodyParser.urlencoded())
// app.use(cors())
// app.use(bodyParser.json())
// app.get('/', (req, res) => {
// res.send('Hello World!')
// })
// app.use("/posts", postRouter)
app.listen(port, () => {
console.log(`Hackathon express app listening on port ${port}`)
})