From 14e0cba5df8e7c5ebcd888ad9f5965230972d4ff Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Thu, 29 Feb 2024 08:17:19 +0100 Subject: [PATCH] Added missing bricks save --- app.py | 15 ++++++++++++--- lego.py | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 319db75..8a4968f 100644 --- a/app.py +++ b/app.py @@ -35,13 +35,22 @@ def save_number(): json_file = json.loads(info.read()) print(json_file['count']) - print(json_file['unit'][0]['bricks']['missing']) + data = ''' + { + "brick" : { + "ID": ''' + data1 + ''', + "color_name": ''' + data2 + ''', + "amount":''' + number + ''' + } + } + ''' + json_file['unit'][0]['bricks']['missing'].append(data) # Save number to JSON file with open('data.json', 'w') as json_file: - json.dump({'number': number}, json_file) + json.dump(json_file, json_file) return ('', 204) if __name__ == '__main__': - app.run(host='192.168.10.109', debug=True, port=3333) + app.run(host='23.88.46.240', debug=True, port=3333) diff --git a/lego.py b/lego.py index a8ea4e7..9cdc4f2 100644 --- a/lego.py +++ b/lego.py @@ -12,7 +12,7 @@ import shutil # save img locally log_name='lego.log' -logging.basicConfig(filename=log_name, encoding='utf-8', level=logging.DEBUG) +logging.basicConfig(filename=log_name, level=logging.DEBUG) logging.FileHandler(log_name,mode='w') set_num=sys.argv[1]