-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a70091d
Showing
1,290 changed files
with
173,988 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5502 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
,fabien,fabien-zenbook,11.11.2021 11:16,file:///home/fabien/snap/libreoffice/236/.config/libreoffice/4; |
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Tuto ici : https://expressjs.com/en/starter/hello-world.html | ||
// https://www.w3schools.com/nodejs/nodejs_mysql.asp | ||
|
||
var express = require('express') | ||
var app = express() | ||
|
||
var mysql = require('mysql') | ||
var con = mysql.createConnection({ | ||
host: 'localhost', | ||
user: 'fabino', | ||
password: 'MonopolI', | ||
database: 'movies', | ||
}) | ||
|
||
con.connect(function (err) { | ||
if (err) throw err | ||
console.log('Connected!') | ||
}) | ||
|
||
var cors = require('cors') | ||
app.use( | ||
cors({ | ||
origin: "*", | ||
}) | ||
); | ||
|
||
// respond with "hello world" when a GET request is made to the homepage | ||
app.get('/', function (req, res) { | ||
res.send('hello world') | ||
}) | ||
|
||
// get 20 first movies | ||
app.get('/api/movies', function (req, res) { | ||
con.query( | ||
'SELECT * FROM movies LIMIT 20;', | ||
function (err, result) { | ||
if (err) throw err | ||
res.send(result); | ||
|
||
} | ||
) | ||
}) | ||
|
||
// get all movies for search in | ||
app.get('/api/allmovies', function (req, res) { | ||
con.query('SELECT * FROM movies;', function (err, result) { | ||
if (err) throw err | ||
res.send(result) | ||
}) | ||
}) | ||
|
||
|
||
app.get('/api/genres', function (req, res) { | ||
con.query( | ||
'SELECT * FROM genres;', | ||
function (err, result) { | ||
if (err) throw err | ||
res.send(result); | ||
} | ||
) | ||
}) | ||
|
||
app.get('/api/producers', function (req, res) { | ||
con.query( | ||
'SELECT id,name FROM producers;', | ||
function (err, result) { | ||
if (err) throw err | ||
res.send(result); | ||
} | ||
) | ||
}) | ||
|
||
app.get('/api/movies/:id', function (req, res) { | ||
con.query("SELECT * FROM movies WHERE id =" + req.params['id'], function (err, result) { | ||
if (err) throw err; | ||
res.send(result); | ||
}); | ||
}) | ||
|
||
app.get('/api/movies/:id/genres', function (req, res) { | ||
con.query("SELECT name FROM genres WHERE id IN (SELECT genre_id FROM movies WHERE id = " + req.params['id'] + " );", function (err, result) { | ||
if (err) throw err; | ||
res.send(result); | ||
}); | ||
}) | ||
|
||
app.get('/api/movies/:id/producers', function (req, res) { | ||
con.query("SELECT name FROM producers WHERE id IN (SELECT producer_id FROM movies WHERE id = " + req.params['id'] + " );", function (err, result) { | ||
if (err) throw err; | ||
res.send(result); | ||
}); | ||
}) | ||
|
||
app.listen(8000, () => { | ||
console.log("Serveur à l'écoute") | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="fr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<link rel="stylesheet" href="style.css"/> | ||
<title>Movies App</title> | ||
</head> | ||
<body> | ||
|
||
<header> | ||
<h1 class="title">My Movies</h1> | ||
<form id="form"> | ||
<input type="text" id="search" class="search" placeholder="Search"> | ||
</form> | ||
</header> | ||
<div class="decal"></div> | ||
|
||
<main id="main"> | ||
|
||
</main> | ||
|
||
<script type= "text/javascript" src="script.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.