From e2d8d04c048589010cfd7e33c865e65ad45e880c Mon Sep 17 00:00:00 2001 From: Lukian Date: Fri, 27 Dec 2024 14:25:22 +0100 Subject: [PATCH] Fixed client scripts --- company/Dockerfile | 5 +++ client/entreprise.py => company/main.py | 22 ++++++---- shareholder/Dockerfile | 5 +++ client/actionnaire.py => shareholder/main.py | 42 +++++++++++--------- 4 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 company/Dockerfile rename client/entreprise.py => company/main.py (66%) create mode 100644 shareholder/Dockerfile rename client/actionnaire.py => shareholder/main.py (57%) diff --git a/company/Dockerfile b/company/Dockerfile new file mode 100644 index 0000000..d6d573a --- /dev/null +++ b/company/Dockerfile @@ -0,0 +1,5 @@ +FROM python:alpine +WORKDIR /app +COPY . . +CMD ["python", "-u", "main.py"] + diff --git a/client/entreprise.py b/company/main.py similarity index 66% rename from client/entreprise.py rename to company/main.py index 4ecbd93..41ef3f8 100644 --- a/client/entreprise.py +++ b/company/main.py @@ -1,13 +1,15 @@ import requests +HOST = "http://localhost:3000/" + """Affichage des actions mises en vente par une entreprise input : - idComp : Identifiant de l'entreprise """ def showShares(idComp): - url = '192.168.200.15/api/companies/'+idComp+'/shares' + url = HOST + 'api/companies/'+idComp+'/shares' r = requests.get(url) - print(r.text) + return r.json() """Création d'une action par une entreprise input : @@ -15,22 +17,26 @@ def showShares(idComp): - price : prix de l'action sur le marché """ def newShare(idComp, price): - url = '192.168.200.15/api/shares/emmit' + url = HOST + 'api/shares/emmit' obj={'id':idComp,'price':price} r = requests.post(url, json=obj) - print(r.text) + return r.json() """Affichage des informations d'une enteprise input : - idComp : identifiant de l'entreprise """ def showInfoComp(idComp): - url='192.168.200.15/api/companies/'+idComp + url = HOST + 'api/companies/'+idComp r=requests.get(url) - print(r.text) + return r.json() """Affichage les enteprises """ def showComp(): - url='192.168.200.15/api/companies/' + url = HOST + 'api/companies/' r=requests.get(url) - print(r.text) \ No newline at end of file + return r.json() + +if __name__ == "__main__": + pass + diff --git a/shareholder/Dockerfile b/shareholder/Dockerfile new file mode 100644 index 0000000..d6d573a --- /dev/null +++ b/shareholder/Dockerfile @@ -0,0 +1,5 @@ +FROM python:alpine +WORKDIR /app +COPY . . +CMD ["python", "-u", "main.py"] + diff --git a/client/actionnaire.py b/shareholder/main.py similarity index 57% rename from client/actionnaire.py rename to shareholder/main.py index b522be8..b8ab1a8 100644 --- a/client/actionnaire.py +++ b/shareholder/main.py @@ -1,51 +1,57 @@ import requests +HOST = "http://localhost:3000/" + """Achat d'une action par un actionnaire à une entreprise input : - idBuyer : identifiant de l'actionnaire - idShare : identifiant de l'action """ -def buy(idBuyer, idShare): - url = '192.168.200.15/api/shares/buy' +def buyShare(idBuyer, idShare): + url = HOST + 'api/shares/buy' obj={'id':idBuyer,'share_id':idShare} r = requests.post(url, json=obj) - print(r.text) + return r.json() """Affichage les actions possédées par un actionnaire input : - idBuyer : identifiant de l'actionnaire """ -def showSharesOf(idBuyer): - url = '192.168.200.15/api/shareholders/'+idBuyer+'/shares' +def getSharesOf(idBuyer): + url = HOST + 'api/shareholders/'+idBuyer+'/shares' r = requests.get(url) - print(r.text) + return r.json() """Affichage les informations d'une actions input : - idShare : identifiant de l'action """ -def showShare(idShare): - url = '192.168.200.15/api/shares/'+idShare +def getShare(idShare): + url = HOST + 'api/shares/'+idShare r = requests.get(url) - print(r.text) + return r.json() """Affichage les actions en circulation sur le marché (possédées ou en vente) """ -def showAllShares(): - url = '192.168.200.15/api/shares' +def getAllShares(): + url = HOST + 'api/shares' r = requests.get(url) - print(r.text) + return r.json() """Affichage les informations sur un actionnaire input : - idBuyer : identifiant de l'actionnaire """ -def showInfoBuyer(idBuyer): - url='192.168.200.15/api/shareholders/'+idBuyer +def getInfoBuyer(idBuyer): + url = HOST + 'api/shareholders/'+idBuyer r=requests.get(url) - print(r.text) + return r.json() """Affichage tous les actionnaires """ -def showAllBuyers(): - url='192.168.200.15/api/shareholders/' +def getAllBuyers(): + url = HOST + 'api/shareholders/' r=requests.get(url) - print(r.text) \ No newline at end of file + return r.json() + +if __name__ == "__main__": + pass +