-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (20 loc) · 701 Bytes
/
app.js
File metadata and controls
27 lines (20 loc) · 701 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
const express = require('express');
const morgan = require('morgan')
const bodyParser = require('body-parser')
// Port and host
const port = 3000;
const hostname = 'localhost';
const app = express();
app.use(express.static(__dirname + '/public'))
app.use(bodyParser.json())
app.use(morgan('dev'));
const coursesRouter = require('./routers/coursesRouter')
// Routes
app.use('/api/courses', coursesRouter)
// Default Routes
app.use((req, res, next) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
res.end('<html><body><h1>This is an Express Server</h1></body></html>');
});
app.listen(port, hostname, () => console.log(`Server listen http://${hostname}:${port} ...`))