文件和视频的支持api (#71)

* 增加视频api、获取文件信息接口
This commit is contained in:
LVtomatoJ 2024-01-30 11:27:12 +08:00 committed by GitHub
parent 23e3dd3c11
commit ab8ddb736e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,6 +258,27 @@ 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/<path:filePath>', 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/<path:savePath>', methods=["GET", 'POST'])
def get_audio(savePath):