feat: 点标注文件下载

This commit is contained in:
maxmon 2022-04-16 22:16:52 +08:00
parent fc9d458495
commit 1b2cd2deeb
2 changed files with 12 additions and 2 deletions

View File

@ -96,6 +96,15 @@ def get_lables():
ret_info.errMsg = str(e)
return json.dumps(download_json, default=lambda o: o.__dict__)
@api.route('/get_anno_json', methods=['GET'])
def get_anno_json():
project_name = request.args.get("projectName")
anno_json_path = DOWNLOAD_FILE_LOCATION.format(project_name).replace('result.json', 'anno.json')
print(anno_json_path)
response = make_response(send_from_directory(directory='', path=anno_json_path, as_attachment=True))
response.headers["Content-disposition"] = 'attachment; filename=result.json'
return response
@api.route('/get_json', methods=['GET'])
def get_json():

View File

@ -624,11 +624,12 @@ export default {
// url
if (this.projectType === '命名实体识别') {
window.open(`/v1/files/get_json?projectName=${this.projectName}`, '_self')
}
if (this.projectType === '文本分类') {
} else if (this.projectType === '文本分类') {
get(`/v1/files/get_labels?projectName=${this.projectName}`, (text) => {
saveAsFile(JSON.stringify(JSON.parse(text)), 'labels.json')
}, {isDirect: true})
} else {
window.open(`/v1/files/get_anno_json?projectName=${this.projectName}`, '_self')
}
return true
}