def get_categories(): categories = getFile('categories') return json.dumps({ "success": True, "data": convertToJsonArray(categories) }), 200, { "ContentType": "application/json" }
def save_file(): file = request.headers.get("file") data = json.loads(request.data) dummy = getFile(file) print('YUAP', data) print('YEP', dummy['item']) duplicated = data[0]['item'] in dummy['item'].values if not duplicated: dummy = dummy.append(data, ignore_index=True) print('saved to file', file, dummy.tail(5)) writeFile(file, dummy) return json.dumps({"success":True}), 200, {"ContentType":"application/json"} return json.dumps({"success":False, "data":"duplicated"}), 200, {"ContentType":"application/json"}
def get_subcategories(): file = request.headers.get("source") if (file == 'subCategories' or file == 'maps'): df = getFile(file) return json.dumps({ "success": True, "data": convertToJsonArray(df) }), 200, { "ContentType": "application/json" } return json.dumps({ "success": False, "data": "unknownFile" }), 200, { "ContentType": "application/json" }