-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
39 lines (29 loc) · 1.07 KB
/
index.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
const express = require('express');
const exphbs = require("express-handlebars");
const bodyParser = require("body-parser");
const path = require("path");
const app = express();
const hbs = require("hbs");
const Doctor = require("./models/doctor");
const Patient = require("./models/patient");
const Book = require("./models/appointment");
const { json } = require("express");
const port = process.env.port || 5000;
const static_path = path.join(__dirname, "../public");
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(static_path));
app.set("view engine", "hbs");
main().catch(err => console.log(err));
async function main() {
app.use(express.static(__dirname + '/public'));
app.set('views', path.join(__dirname, 'views'));
const handlebars = exphbs.create({ extname: "hbs" });
app.engine('hbs', handlebars.engine);
app.set('view engine', 'hbs');
const routes = require('./server/routes/app');
app.use('/', routes);
app.listen(port, () => {
console.log(`Listening from port ${port}`);
})
}