From d82ae7560cbb7946df0a7c249c7b8e0f26fc7f0b Mon Sep 17 00:00:00 2001 From: lvtomatoj Date: Mon, 29 Jan 2024 14:25:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/api/api.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pywxdump/api/api.py b/pywxdump/api/api.py index 4646d07..9ef6d67 100644 --- a/pywxdump/api/api.py +++ b/pywxdump/api/api.py @@ -257,6 +257,28 @@ def get_video(videoPath): return ReJson(5002) return send_file(all_video_path) +@api.route('/api/file_info', methods=["GET", 'POST']) +def get_file_info(): + file_path = request.args.get("file_path") + file_path = request.json.get("file_path", file_path) + if not file_path: + return ReJson(1002) + wx_path = read_session(g.sf, "wx_path") + all_file_path = os.path.join(wx_path, file_path) + if not os.path.exists(all_file_path): + return ReJson(5002) + file_name = os.path.basename(all_file_path) + file_size = os.path.getsize(all_file_path) + return ReJson(0, {"file_name": file_name, "file_size": str(file_size)}) + +@api.route('/api/file/', methods=["GET", 'POST']) +def get_file(filePath): + wx_path = read_session(g.sf, "wx_path") + all_file_path = os.path.join(wx_path, filePath) + if not os.path.exists(all_file_path): + return ReJson(5002) + return send_file(all_file_path) + @api.route('/api/audio/', methods=["GET", 'POST']) def get_audio(savePath): # savePath = request.args.get("savePath")