This file contains hidden or 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
    
  
  
    
  | REQUEST / index.js | |
| app.get('/api/movies', (req, res) =>{ | |
| let sql = 'SELECT * from movie'; | |
| const sqlValues = []; | |
| if(req.query.genre && req.query.rating){ | |
| sql += ' WHERE genre = "Fantasy" AND rating =3'; | |
| sqlValues.push(req.query.genre && req.push.rating); | |
| } | |
| connection.query(sql, sqlValues,(err, results) => { | 
  
    
      This file contains hidden or 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
    
  
  
    
  | 1/ | |
| mysql> SELECT name, COUNT(name) AS number FROM team LEFT JOIN player ON team.id=team_id GROUP BY name ORDER BY number DESC; | |
| +------------+--------+ | |
| | name | number | | |
| +------------+--------+ | |
| | Gryffindor | 36 | | |
| | Slytherin | 21 | | |
| | Ravenclaw | 15 | | |
| | Hufflepuff | 12 | | |
| +------------+--------+ | 
  
    
      This file contains hidden or 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
    
  
  
    
  | 1/ | |
| mysql> SELECT lastname, firstname, role, name from player join wizard on wizard.id=wizard_id join team on team.id=team_id order by name, role, lastname,firstname asc; | |
| +-----------------+-------------+--------+------------+ | |
| | lastname | firstname | role | name | | |
| +-----------------+-------------+--------+------------+ | |
| | Black | Sirius | beater | Gryffindor | | |
| | Brown | Lavender | beater | Gryffindor | | |
| | Finnigan | Seamus | beater | Gryffindor | | |
| | Hagrid | Rubeus | beater | Gryffindor | | |
| | Longbottom | Alice | beater | Gryffindor | | 
  
    
      This file contains hidden or 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; | |
| const connection = require('./conf'); | |
| app.use(express.json()); | |
| // Support URL-encoded bodies | |
| app.use(express.urlencoded({ | |
| extended: true | |
| })); | 
  
    
      This file contains hidden or 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; | |
| const connection = require('./conf'); | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ | |
| extended: true | |
| })); | |
| app.put('/api/movies/:id', (req, res)=>{ | 
  
    
      This file contains hidden or 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; | |
| const connection = require('./conf'); | |
| app.use(express.json()); | |
| // Support URL-encoded bodies | |
| app.use(express.urlencoded({ | |
| extended: true | |
| })); | 
  
    
      This file contains hidden or 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; | |
| const connection = require('./conf'); | |
| app.get('/api/movies', (req, res) =>{ | |
| connection.query('SELECT * from movie', (err, results) => { | |
| if (err) { | |
| res.status(500).send('Erreur lors de la récupération des films'); | |
| } else { | 
  
    
      This file contains hidden or 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("Récupération de tous les films"); | |
| }); | |
| app.get(`/api/movies/:id`, (request, response) => { | |
| const id_movie = request.params.id; | 
  
    
      This file contains hidden or 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 http = require('http'); | |
| const url = require ('url'); | |
| const port = 8000; | |
| const requestHandler = (request, response) => { | |
| const myParsedUrl = url.parse(`/${request.url}`,true); | |
| const donnesUrl = myParsedUrl.query; | |
| if (request.url === '/' || request.url === '/?name=' || request.url === '/?name=&city=' || request.url === '/?city=') { | |
| response.end('Please provide name AND city parameters'); | 
  
    
      This file contains hidden or 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
    
  
  
    
  | ### GET api.kerokuapp.com (no parameter) | |
| GET https://http-practice.herokuapp.com/wilders | |
| ### GET api.kerokuapp.com (parameters language and page) | |
| GET https://http-practice.herokuapp.com/wilders?language=JavaScript&page=20 | |
| ###POST api.kerokuapp.com (insertion data in form-urlencoded, parameters name and language) | |
| POST https://http-practice.herokuapp.com/wilders | |
| Content-Type: application/x-www-form-urlencoded | 
NewerOlder