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 assert = require('assert'); | |
class BankCustomer { | |
constructor (name, code) { | |
let namePrivacy = name; | |
let codeSecret = code; | |
this.getName = () => namePrivacy; | |
this.verifyPinInput = function(input) { | |
if (input === codeSecret) { | |
return true; |
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
mysql> SELECT * FROM wizard WHERE birthday BETWEEN '1975-01-01' AND '1985-01-01'; | |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+ | |
| id | firstname | lastname | birthday | birth_place | biography | is_muggle | | |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+ | |
| 1 | harry | potter | 1980-07-31 | london | | 0 | | |
| 2 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 | | |
| 4 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 | | |
| 5 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 | | |
| 6 | fred | weasley | 1978-04-01 | | | 0 | | |
| 7 | george | weasley | 1978-04-01 | | |
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
mysql> CREATE DATABASE kaamelott; | |
Query OK, 1 row affected (0.01 sec) | |
mysql> USE kaamelott; | |
Database changed | |
mysql> CREATE TABLE knight ( | |
-> id INT PRIMARY KEY AUTO_INCREMENT NOT NULL, | |
-> name VARCHAR(80), | |
-> age INT |
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 http = require("http"); | |
const port = 3000; | |
const requestHandler = (request, response) => { | |
console.log(request.url); | |
let sentence; | |
let url = request.url.split('/'); | |
console.log(url[1]); | |
switch(url[1]){ | |
case 'contact' : |
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
mysql> INSERT INTO school (name, country, capacity) | |
-> VALUES ("Beauxbatons Academy of Magic", "France", 550), | |
-> ("Castelobruxo", "Brazil", 380), | |
-> ("Durmstrang Institute", "Norway", 570), | |
-> ("Hogwarts School of Witchcraft and Wizardry", "United Kingdom", 450), | |
-> ("Ilvermorny School of Witchcraft and Wizardry", "USA", 300), | |
-> ("Koldovstoretz", "Russia", 125), | |
-> ("Mahoutokoro School of Magic", "Japan", 800), | |
-> ("Uagadou School of Magic", "Uganda", 350); |
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("Récupération de tous les films"); | |
}); | |
app.get('/api/movies/:id', (req, response) => { | |
const id = req.params.id; | |
response.json({ id: `${id}` }); |
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 = 3001; | |
const connection = require("./conf"); | |
app.get("/api/movies", (req, res) => { | |
connection.query("SELECT * from movie", (err, results) => { | |
if (err) { |
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; | |
const connection = require("./conf"); | |
const bodyParser = require("body-parser"); | |
app.get("/api/movies", (req, res) => { | |
connection.query("SELECT * from movie", (err, results) => { | |
if (err) { |
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
app.put("/api/movies/:id", (req, res) => { | |
const formData = req.body; | |
const idMovie = req.params.id; | |
connection.query("UPDATE movie SET ? WHERE id=?", [formData, idMovie], err => { | |
if (err){ | |
console.log(err); | |
res.status(500).send("erreur lors de la modification"); | |
}else{ | |
res.sendStatus(200); | |
} |
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
app.delete('/api/movies/:id', (req, res) => { | |
const idMovie = req.params.id; | |
connection.query('DELETE FROM movie WHERE id = ?', [idMovie], err => { | |
if (err) { | |
console.log(err); | |
res.status(500).send("Erreur lors de la suppression d'un film"); | |
} else { | |
res.sendStatus(200); | |
} | |
}); |