From bf1e49431863fe6b13961e9b6e48b1a10d93a1ac Mon Sep 17 00:00:00 2001 From: nsde Date: Tue, 25 Jul 2023 12:47:26 +0200 Subject: [PATCH] ToS check JSON decode error fix --- web/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/app.py b/web/app.py index 9b37947..b646406 100644 --- a/web/app.py +++ b/web/app.py @@ -64,7 +64,11 @@ def create_app() -> flask.Flask: if not os.path.exists('data/tos.json'): open('data/tos.json', 'w', encoding='utf8').write('{}') - data = json.load(open('data/tos.json', encoding='utf8')) + try: + data = json.load(open('data/tos.json', encoding='utf8')) + except json.decoder.JSONDecodeError: + data = {} + data[code] = emoji json.dump(data, open('data/tos.json', 'w', encoding='utf8'))