test-1 / services /utils.py
vmoras's picture
Initial commit
7083742
raw
history blame contribute delete
547 Bytes
import os
import json
def create_folder(path):
if not os.path.exists(path):
os.makedirs(path)
def save_json(file_path, data):
if os.path.exists(file_path):
json_data = load_json(file_path)
json_data['appointments'].append(data)
else:
json_data = {'appointments': [data]}
with open(file_path, 'w', encoding='utf-8') as outfile:
json.dump(json_data, outfile, indent=4)
def load_json(file_path):
with open(file_path, 'r', encoding='utf-8') as infile:
return json.load(infile)