- IP : 51.68.18.120
- User : root
- Password : 7U6:5b8989GBS5R
- Découverte de NodeJS
- Installation et utilisation d'un module
- Le protocole HTTP
- Le protocole HTTP - Mise en pratique
- Node.js - Créer un serveur HTTP
- Express 1 - Découverte d'Express
- Express 2 - Express, MySQL, Postman
- Express 3 - Méthode POST et insertion de données
- Express 4 - Méthode PUT et modification de données
- Express 5 - Méthode DELETE et suppression de données
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
process.stdin.resume() | |
process.stdin.setEncoding('utf8') | |
console.log('What\'s your age ? ') | |
process.stdin.on('data', (value) => { | |
const age = parseInt(value, 10); | |
if (isNaN(age)) { | |
console.error("Value is not a number") | |
} else if (age < 0 || age > 99) { | |
console.error("Illegal value") |
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
var cowsay = require("cowsay"); | |
console.log(cowsay.say({ | |
text : "hello boy", | |
e : "^^", | |
T : "U " | |
})); |
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 all wilders | |
GET https://http-practice.herokuapp.com/wilders | |
### get wilder for JavaScript, page 10 | |
GET https://http-practice.herokuapp.com/wilders?language=JavaScript&page=10 | |
### create wilder from url-encoded | |
POST https://http-practice.herokuapp.com/wilders | |
Content-Type: application/x-www-form-urlencoded |
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 url = require('url'); | |
const http = require('http'); | |
const port = 8000; | |
const requestHandler = (request, response) => { | |
const parsedUrl = url.parse(request.url, true); | |
const params = parsedUrl.query; | |
if (params.name && params.city) { | |
response.end(`Hello ${params.name} from ${params.city}!`); | |
} 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', (req, res) => { | |
res.send('Récupération de tous les films'); | |
}); | |
app.get(`/api/movies/:id`, (req, res) => { | |
const id = req.params.id; // récupère John |
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.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |
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.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |