import ast import os def GET(args, ressources): if os.path.exists("states"): file = open("states", 'r') file = file.read() file = ast.literal_eval(file) if args["targetdict"] in file: return file[args["targetdict"]] else: file[args["targetdict"]] = {} file2 = open("states", 'w') file2.write(str(file)) file2.close() return {} else: file = open("states", 'w') file.write(str({})) file.close() return {} def PATCH(args, ressources): if os.path.exists("states"): file = open("states", 'r') file = file.read() file = ast.literal_eval(file) else: file = {} print(args) file[args["targetdict"]] = ast.literal_eval(args["dict"]) file2 = open("states", 'w') file2.write(str(file)) file2.close()