-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (22 loc) · 836 Bytes
/
server.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
/* server.js - Express server*/
'use strict';
const log = console.log
log('Express server')
const express = require('express')
const app = express();
const path = require('path');
app.use(express.static(path.join(__dirname, '/pub')))
app.get('/', (req, res) => {
res.send('<h1>root route. Go to /examples.html to see example</h1>')
})
// Error codes
app.get('/problem', (req, res) => {
res.status(500).send('There was a problem on the server')
})
// will use an 'environmental variable', process.env.PORT, for deployment.
const port = process.env.PORT || 5000
app.listen(port, () => {
log(`Listening on port ${port}...`)
}) // localhost development port 5000 (http://localhost:5000)
// We've bound that port to localhost to go to our express server.
// Must restart web server when you make changes to route handlers.