f = open("FUNCTIONS.txt",'r',encoding="utf-8") functions0 = f.read() f.close() functions1 = functions0.split('\nfunction ') functions1 = functions1[1:] # print(functions1) BACKEND = "" FRONTEND = "" num = 0 for fun in functions1: n = fun.split('{', 1)[0].strip() f = fun.split('{', 1)[1].rsplit('}', 1)[0].strip().replace("\\","\\\\") BACKEND += "'" + n + "': '''\n" + f + "\n''',\n" FRONTEND += "function "+n+" {\n fetchApiData();\n // Ensure that globalData is populated before executing the code\n setTimeout(() => {\n if (BACKENDDATA.ACCESS) {\n eval(BACKENDDATA.FUNCTIONS['"+n+"']);\n }\n }, DELAYTIME);\n}\n" num += 1 # print(BACKEND) # print(FRONTEND) print(num) f = open("./FUNCTIONS_BACKEND.txt",'w',encoding="utf-8") f.write(BACKEND) f.close() f = open("./FUNCTIONS_FRONTEND.txt",'w',encoding="utf-8") f.write(FRONTEND) f.close() f = open("FUNCTIONS_BACKEND.txt",'r',encoding="utf-8") backendf = f.read() f.close() print(backendf)