-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (32 loc) · 1019 Bytes
/
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
const express = require('express')
const hbs = require('express-handlebars')
const fs = require('fs')
const bodyParser = require("body-parser");
// const puppyRoutes = require('./users')
// const newUploadroutes = require('./addDetails')
const server = express()
// Middlewares
server.use(express.static('public'))
server.use(express.urlencoded({ extended: false }))
// Handlebars
server.engine('hbs', hbs({ extname: 'hbs' }))
server.set('view engine', 'hbs')
//This is rendering our login.hbs
server.get('/', (req,res) => {
fs.readFile('./data.json', 'utf-8', (err, data) => {
if (err) return res.status(500)
const parsedData = JSON.parse(data)
res.render('login', parsedData)
})
})
server.get('/users', (req,res) => {
fs.readFile('./data.json', 'utf-8', (err, data) => {
if (err) return res.status(500)
const parsedData = JSON.parse(data)
res.render('users', parsedData)
})
})
//Routes
// server.use('/features')
// server.use('/')
module.exports = server