Created
May 15, 2019 10:07
-
-
Save Nocktiss/ed784bc94f286c6eea50b84fa96834f1 to your computer and use it in GitHub Desktop.
nodeExpress
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('/', (req, res) => { | |
res.send('Bienvenue sur Express') | |
}) | |
app.get('/api/movies', (req, res) => { | |
res.send('Récupération de tous les films') | |
}) | |
app.get('/api/movies/:id', (req, res) => { | |
const id = req.params.name; | |
res.json({id}) | |
}) | |
app.get('/api/employee/', (req, res) => { | |
const name = req.query.name; | |
if (name) { | |
res.status(404).send(`Impossible de récupérer l'employé ${name}`) | |
} else { | |
res.sendStatus(304) | |
} | |
}) | |
app.listen(port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment