-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (25 loc) · 1 KB
/
server.js
File metadata and controls
34 lines (25 loc) · 1 KB
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
const express = require('express');
const dotenv = require('dotenv');
const morgan = require('morgan');
const bodyparser = require('body-parser');
const path = require('path');
// initialize this app as express app
const app = express();
dotenv.config({path:'config.env'})
// add some change after see "Crid Application" on the localhost
const PORT = process.env.PORT || 8080
//log requests
app.use(morgan('tiny'));
// parse request to body-parser
app.use(bodyparser.urlencoded({extended:true}))
// set view engine
app.set("view engine","ejs")
//app.set("view",path.resolve(__dirname,"views/ejs"))
// Up is for the ejs files are directly under views
// load assets
app.use('/css',express.static(path.resolve(__dirname,"assets/css")))
app.use('/img',express.static(path.resolve(__dirname,"assets/img")))
app.use('/js',express.static(path.resolve(__dirname,"assets/js")))
//load routers
app.use('/',require('./server/routes/router'))
app.listen(PORT,()=>{console.log('Server is running on http://localhost:$(PORT)')})