Created
May 21, 2019 08:13
-
-
Save dragonslayer77/fd990b8850752ea6ec377fa082585776 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/api/movies', (request, response) => { | |
response.send('All Films'); | |
}); | |
app.get('/api/movies/:id', (request, response) => { | |
response.json({id: request.params.id}); | |
}); | |
app.get('/api/employee', (request, response)=> { | |
const name = request.query.name; | |
if (name) { | |
response.status(404).send('Unable to retrieve employee ' + name); | |
} else { | |
response.sendStatus(304); | |
} | |
}); | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} | |
console.log(`Server is listening on ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment