ToS check JSON decode error fix

This commit is contained in:
nsde 2023-07-25 12:47:26 +02:00
parent 50dd4dedb2
commit bf1e494318

View file

@ -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('{}')
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'))