Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const port = 3000;
- const movie = "Juno"
- app.get('/', (request, response) => {
- response.send('Welcome to Express');
- });
- app.get('/api/movies', (request, response) => {
- response.send(`Tonight at 19:30 this is the movie I am playing: ${movie}`);
- });
- app.get('/api/movies/:title', (request, response) => {
- response.json({id: request.params.title});
- });
- app.get('/api/employee', (request, response) => {
- //The 304 status gets cancelled but 200 + 200 = 304
- response.status(200).send('There are people that work here');
- response.status(200).send('There are people that work here');
- });
- app.get('/api/employees', (request, response) => {
- const name = request.query.name;
- response.status(404).send(`There is nobody working here called: ${name}`);
- });
- app.listen(port, (err) => {
- if (err) {
- throw new Error('Something bad happened...');
- }
- console.log(`Server is listening on ${port}`);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement