-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (39 loc) · 1.08 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const express = require("express");
const exphbs=require("express-handlebars");
const bodyParser=require("body-parser");
const mysql=require("mysql");
const Connection = require("mysql/lib/Connection");
require('dotenv').config;
const app=express();
const port=process.env.PORT || 5000;
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
//Static Files
app.use(express.static("public"));
//Template Engine
const handlebars =exphbs.create({extname:".hbs"});
app.engine('hbs',handlebars.engine);
app.set("view engine","hbs");
//Mysql
/* const con=mysql.createPool({
connectionLimit:10,
host:process.env.DB_HOST,
user:process.env.DB_USER,
password:process.env.DB_PASS,
database:process.env.DB_NAME
});
//Check Database Connection
con.getConnection((err,connection)=>{
if(err) throw err
console.log("Connection Success");
}); */
//Router
/* app.get('/',(req,res)=>{
res.render("home");
}); */
const routes=require("./server/routes/students");
app.use('/',routes);
//listen Port
app.listen(port,()=>{
console.log("Listening Port:"+port);
})