-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (26 loc) · 810 Bytes
/
app.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
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const cors = require('cors');
//DB config
require('./public/config/db')
const app = express();
const demo = require('./routes/demo')
//Set publiic folder
app.use(express.static(path.join(__dirname, '/public')));
//body parser middleware from documention
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
//home page
app.get("/", function(req, res){
res.render("./public/index.html");
});
//router to demo
app.use('/demo', demo);
//enable CORS
app.use(cors());
const port = 3000;
app.listen(port, ()=>console.log('Server started on port ${port}'));
// app.listen(process.env.PORT, process.env.IP, function(){
// console.log("The Server Has Started!");
// });