mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 10:30:17 +01:00
intégration backend / api
backend avec api d'ajout d'avis (note principale uniquement)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import requests
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
@@ -23,6 +24,7 @@ class WebsocketServer(threading.Thread):
|
||||
async def handler(self,websocket):
|
||||
while True:
|
||||
for msg in self.messageQueue:
|
||||
# print("sending", json.dumps(msg))
|
||||
await websocket.send(json.dumps(msg))
|
||||
self.messageQueue.pop(0)
|
||||
await asyncio.sleep(0.01)
|
||||
@@ -34,4 +36,14 @@ class ApiClient():
|
||||
def __init__(self, host=os.getenv("API_HOST"), port=os.getenv("API_PORT")):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
||||
|
||||
def send(self,note,note_autre):
|
||||
#Exemple ajout d'un commentaire depuis la borne (site ou geste)
|
||||
avis = {
|
||||
"note": note,
|
||||
"source": "borne",
|
||||
"commentaire":"",
|
||||
#Optionel
|
||||
"notes_autre": '{"proprete":'+str(note_autre)+',"calme":10}',
|
||||
}
|
||||
return requests.post("http://"+self.host+":"+self.port+"/add_review", data=avis)
|
||||
|
||||
Reference in New Issue
Block a user