-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (22 loc) · 751 Bytes
/
app.js
File metadata and controls
33 lines (22 loc) · 751 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
const express = require('express');
const http = require('http');
const expressEjsLayout = require('express-ejs-layouts');
const path = require('path');
const indexRouter = require('./routes/index');
require('dotenv').config();
var app = express();
var server = http.createServer(app);
const port = process.env.PORT;
// Parse URL-encoded bodies (as sent by HTML forms)
app.use(express.urlencoded());
//Parse JSON bodies (as sent by API clients)
app.use(express.json());
app.use(expressEjsLayout);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use('/', indexRouter);
server.listen(port, () => {
console.log(`Server is up on port ${port}`);
});