Skip to content

Instantly share code, notes, and snippets.

@alyson-b69
alyson-b69 / gist:191c6d91fc8fe5e54ca5d02800ae3c00
Created September 8, 2020 11:08
EXPRESS - Méthode POST insertion de données
const express = require("express");
const app = express();
const port = 3000;
const connection = require("./conf");
// Support JSON-encoded bodies
app.use(express.json());
// Support URL-encoded bodies
app.use(
express.urlencoded({
extended: true,
@alyson-b69
alyson-b69 / gist:98bff77095c24591d9a32e6bec7616dd
Created September 8, 2020 10:31
Express 2 - EXPRESS MySQL POSTMAN
const express = require("express");
const app = express();
const port = 3000;
const connection = require("./conf");
app.get("/api/employees", (req, res) => {
connection.query("SELECT * from employee", (err, results) => {
if (err) {
res.status(500).send(err);
} else {
const express = require("express");
const { response } = require("express");
const app = express();
const port = 3000;
app.get("/", (request, response) => {
response.send("Bienvenue sur Express");
});
app.get("/api/movies", (req, res) => {
@alyson-b69
alyson-b69 / gist:ee784dffafe5eb692f773d5abe589f7b
Created September 8, 2020 08:06
NodeJS Créer un serveur
const http = require("http");
const url = require("url");
const port = 8000;
const requestHandler = (request, response) => {
if (request.url === "/") {
response.end("Please provide name and city parameters si l'url");
} else {
let queryS = url.parse(request.url, true).query;
@alyson-b69
alyson-b69 / gist:b91c83462adf2a1fdc20e0e6adba5f6a
Created September 7, 2020 10:20
SQL Manipulation de données WILD Quest
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);
Query OK, 8 rows affected (0,00 sec)
mysql> SELECT * FROM wizard WHERE birthday BETWEEN '1975-01-01' AND '1985-01-01';
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| id | firstname | lastname | birthday | birth_place | biography | is_muggle |
+----+-----------+----------+------------+-------------+---------------------------------------+-----------+
| 14 | harry | potter | 1980-07-31 | london | | 0 |
| 15 | hermione | granger | 1979-09-19 | | Friend of Harry Potter | 0 |
| 17 | ron | weasley | 1980-03-01 | | Best friend of Harry | 0 |
| 18 | ginny | weasley | 1981-08-11 | | Sister of Ron and girlfriend of Harry | 0 |
| 19 | fred | weasley | 1978-04-01 | | | 0 |
| 20 | george | weasley | 1978-04-01 | |
### GET wilders with the API
GET https://http-practice.herokuapp.com/wilders
### GET wilders on JavaScript with the API
GET https://http-practice.herokuapp.com/wilders?language=JavaScript
### GET wilders on JavaScript with the API & a big number
GET https://http-practice.herokuapp.com/wilders?language=JavaScript&page=100000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css" />
<title>Document</title>
</head>
<body>
<header>
(function () {
let dataClinics = [
{
id: 1,
clinic: 'The Smiling House',
img_clinique:'https://www.lasource.ch/sites/default/files/styles/crop_3_2/public/images/content_types/page/specialites.jpg?itok=1eShRFbt',
city: 'Bucarest',
country: 'Romania',
price:[823,256],
npm install -g cowsay
let cowsay = require("cowsay");
console.log(cowsay.say({
text : "hello boy",
}));