def api_show(): cid = request.form.get("cid") print("cid:", cid) print("request_data:", request.data) # 按课程id查询文件 result = File.queryByCid(cid) print("result:", result) # json数据 jdata = {"code": 0, "msg": "", "count": len(result), "data": []} # data填充 for row in result: data_row = { "fid": "", "fname": "", "furl": "", "fcid": "", "ftime": "", "wno": "" } for key, value in zip(data_row, row): data_row[key] = str(value) jdata["data"].append(data_row) print("jdata:", jdata) # print(cid) # print(result) # print(jdata) # print(jsonify(jdata)) return jsonify(jdata)
def deletecourse(id): course = Course(unique_id=id) file = File.queryByCid(id) print("File:", file) if (len(file) > 0): file_path = file[0][2] file_path = file_path.rsplit('/', 1)[0] print("file_path:", file_path) shutil.rmtree(file_path) File.deleteallBycourseid(id) course.delete() return jsonify({"dd": "dd"})