-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (25 loc) · 845 Bytes
/
index.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
const express = require('express'),
http = require('http');
const hostname = 'localhost';
const port = 3000;
const app = express();
//Morgon for logging purposes
const morgan = require('morgan');
//Adding routers
const bodyParser = require('body-parser');
//dishrouter
const dishRouter = require('./routes/dishRouter');
app.use('/dishes', dishRouter);
//morgan App use
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
app.use((req, res, next) => {
console.log(req.headers);
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
res.end('<html><body><h1>This is an Express Server</h1></body></html>');
});
const server = http.createServer(app);
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});