From cdb865f10c0f56d72211a6f47ea491d6cac7eac5 Mon Sep 17 00:00:00 2001 From: lwadbled Date: Fri, 14 Jan 2022 11:05:31 +0100 Subject: [PATCH] feat(Python): Ajout du code python (pour plus tard avec la raspberry) + tentative resolution de bug sur reservation --- Python/client.py | 8 ++++++++ Python/serveur.py | 9 +++++++++ html/Python/client.py | 8 ++++++++ html/gestionReservation.php | 11 ++++++++--- html/index.html | 2 +- html/menu.php | 2 ++ html/reservation.php | 63 +++++++++++++++++++++++++++++++-------------------------------- 7 files changed, 67 insertions(+), 36 deletions(-) create mode 100644 Python/client.py create mode 100644 Python/serveur.py create mode 100644 html/Python/client.py diff --git a/Python/client.py b/Python/client.py new file mode 100644 index 0000000..12ee50f --- /dev/null +++ b/Python/client.py @@ -0,0 +1,8 @@ +import socket + +if __name__ == '__main__': + clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); + data = "Hello Server!"; + clientSocket.sendto(data.encode(),("172.26.145.62",9090)); + dataFromServer,sourceAddress = clientSocket.recvfrom(1024); + print(dataFromServer.decode()); diff --git a/Python/serveur.py b/Python/serveur.py new file mode 100644 index 0000000..ec866f8 --- /dev/null +++ b/Python/serveur.py @@ -0,0 +1,9 @@ +import socket + +if __name__=='__main__': + server.Socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); + serverSocket.bind(("172.26.145.62",9090)); # Adresse du serveur à modifer selon l'IP de la RASPBERRY (TODO : prendre un argument qui sera donné par le serveur Web) + while(True): + dataFromClient, sourceAddress = serverSocket.recvfrom(1024); + print("Data from %s is %s"%(sourceAddress,dataFromClient.decode())); + serverSocket.sendto("Hello Client!".encode(),sourceAddress); diff --git a/html/Python/client.py b/html/Python/client.py new file mode 100644 index 0000000..12ee50f --- /dev/null +++ b/html/Python/client.py @@ -0,0 +1,8 @@ +import socket + +if __name__ == '__main__': + clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); + data = "Hello Server!"; + clientSocket.sendto(data.encode(),("172.26.145.62",9090)); + dataFromServer,sourceAddress = clientSocket.recvfrom(1024); + print(dataFromServer.decode()); diff --git a/html/gestionReservation.php b/html/gestionReservation.php index ae3aff1..157befb 100644 --- a/html/gestionReservation.php +++ b/html/gestionReservation.php @@ -36,13 +36,18 @@ /* Verification de la syntaxe de la date */ $explosion_date = explode("-",$txtDate); $jour = $explosion_date[2]; + $mois = $explosion_date[1]; + $annee = $explosion_date[0]; if($jour<10){ - $jour = "0$jour"; - $mois = $explosion_date[1]; - $annee = $explosion_date[0]; + $jour = "0$jour"; + $txtDate = "$annee-$mois-$jour"; + } + if($mois<10){ + $mois = "0$mois"; $txtDate = "$annee-$mois-$jour"; } } + echo $txtDate; ?>
diff --git a/html/index.html b/html/index.html index 0549450..b6344f1 100644 --- a/html/index.html +++ b/html/index.html @@ -18,7 +18,7 @@
-