-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
48 lines (32 loc) · 1009 Bytes
/
app.js
File metadata and controls
48 lines (32 loc) · 1009 Bytes
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
const express = require('express')
const routes = require('./api/routes')
const user = require('./api/routes/user')
const app = express()
const mysql = require('mysql')
const port = 3000
let bodyParser =require("body-parser");
let dbconnect = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'db-egil'
});
dbconnect.connect();
global.db = dbconnect;
// Static Files
app.use(express.static('public'))
app.use('/css', express.static(__dirname + 'public/css'))
app.use('/js', express.static(__dirname + 'public/js'))
app.use('/img', express.static(__dirname + 'public/img'))
// all environments
app.set('views','./views')
app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(express.static('public'))
// Request Method
app.get('/',routes.index)
// Listen Port
app.listen(port, () =>
console.info(`Listening on port ${port}`)
)