Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express')
- const app = express()
- const port = 3000
- app.get('/', (req, res) => {
- res.send('Bienvenue sur Express');
- });
- app.get('/api/movies/:id', function (req, res) {
- const id = req.params.id;
- var data = {
- "id": id
- };
- res.send(data);
- });
- app.get('/api/employee', (req, res) => {
- const url = req.url
- if (url === '/api/employee') {
- res.sendStatus(304);
- } else
- res.status(404).send('ERROR 404');
- });
- app.listen(port, (err) => {
- if (err) {
- throw new Error('Something bad happened...');
- }
- console.log(`Server is listening on ${port}`);
- });
Add Comment
Please, Sign In to add comment