diff --git a/app.py b/app.py index 1fd5695..bae85d6 100644 --- a/app.py +++ b/app.py @@ -43,6 +43,10 @@ def stop(id): def show(): # print(request.json) data = request.json["content"] + info(data) + return 'ok' + +def info(data): balls = data["balls"] table = data["table"] text = f"table:{table:>3} " @@ -50,7 +54,6 @@ def show(): ball = "#" if "ball"+str(i) in balls else " " text += f"| {i} : {ball} " print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text) - return 'ok' def worker(id,source,region=None,stream=False): if region == None: @@ -111,7 +114,9 @@ def worker(id,source,region=None,stream=False): names = {} if count < region: continue - json_data = json.dumps({"table":id,"balls":balls,"time":int(time.time()*1000)}) + data = {"table":id,"balls":balls,"time":int(time.time()*1000)} + info(data) + json_data = json.dumps(data) balls = {} count = 0 if not stream: @@ -135,10 +140,10 @@ def workerloop(stop_event,id,source,target=None,region=None): "Content-Type": "application/json" } text = json.dumps({"content":json_data}) - print(text) + # print(text) response = requests.post(target, data=text, headers=headers) - print(response.text) + # print(response.text) finally: gen.close() diff --git a/docker-compose.yaml b/docker-compose.yaml index 9888cec..4c4c90e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,8 +1,8 @@ version: '3' services: billiard: - # command: ["python", "./app.py"] - command: ["gunicorn", "app:app", "--bind", "0.0.0.0:5000", "--timeout", "0", "--workers", "1"] + command: ["python", "./app.py"] + # command: ["gunicorn", "app:app", "--bind", "0.0.0.0:5000", "--timeout", "0", "--workers", "1"] restart: always build: . volumes: diff --git a/show.py b/show.py index 28b610b..5a5e758 100644 --- a/show.py +++ b/show.py @@ -1,6 +1,7 @@ import cv2 import json import time +import logging import requests import supervision as sv @@ -23,6 +24,7 @@ def show(): text += f"| {i} : {ball} " print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'),text) return 'ok' - + if __name__ == '__main__': + app.logger.setLevel(logging.ERROR) app.run("0.0.0.0",threaded=True)