-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (32 loc) · 793 Bytes
/
index.js
File metadata and controls
42 lines (32 loc) · 793 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
34
35
36
37
38
39
40
41
42
/*
file: index.js
type: api
endpoint: http://3.12.171.79:8080
*/
const express = require('express')
const app = express()
const port = process.env.PORT || 8080
app.get('/', (req, res) => {
res.type('text/plain')
res.send('Meadowlark Travel')
})
app.get('/about', (req, res) => {
res.type('text/plain')
res.send('About Meadowlark Travel')
})
// custom 404 page
app.use((req, res) => {
res.type('text/plain')
res.status(404)
res.send('404 - Not Found')
})
// custom 500 page
app.use((err, req, res, next) => {
console.error(err.message)
res.type('text/plain')
res.status(500)
res.send('500 - Server Error')
})
app.listen(port, () => console.log(
`Express started on http://localhost:${port}; ` +
`press Ctrl-C to terminate.`))