fix: [website.query] download

pull/689/head
David Cruciani 2024-08-22 12:16:56 +02:00
parent 230eaf8437
commit 208e1c9b0b
No known key found for this signature in database
GPG Key ID: 8690CDE1E3994B9B
2 changed files with 6 additions and 4 deletions

View File

@ -179,8 +179,10 @@ def download(sid):
if sess:
loc = json.loads(sess.result)
module = request.args.get("module")
if module in loc:
return jsonify(loc[module]), 200, {'Content-Disposition': f'attachment; filename={sess.query_enter.replace(".", "_")}-{module}.json'}
query = request.args.get("query")
if query in loc:
if module in loc[query]:
return jsonify(loc[query][module]), 200, {'Content-Disposition': f'attachment; filename={query}-{module}.json'}
return {"message": "Module not in result", "toast_class": "danger-subtle"}, 400
else:
for s in SessionModel.sessions:
@ -188,7 +190,7 @@ def download(sid):
module = request.args.get("module")
if module in s.result:
return jsonify(s.result[module]), 200, {'Content-Disposition': f'attachment; filename={s.query}-{module}.json'}
return {"message": "Module not in result", "toast_class": "danger-subtle"}, 400
return {"message": "Module not in result ", "toast_class": "danger-subtle"}, 400
return {"message": "Session not found", 'toast_class': "danger-subtle"}, 404
return {"message": "Need to pass a module", "toast_class": "warning-subtle"}, 400

View File

@ -168,7 +168,7 @@
<!-- json part -->
<template v-if="tab_list == 'json'">
<div class="btn-group" role="group" style="padding: 5px; margin-left: 5px; margin-top: 5px;">
<a class="btn btn-primary" :href="`/download/${sid}?module=${key}`" title="Download the json" >Download</a>
<a class="btn btn-primary" :href="`/download/${sid}?query=${key_query}&module=${key}`" title="Download the json" >Download</a>
</div>
<div class="accordion-body" v-html="generateCoreFormatUI(result)[0].outerHTML"></div>
</template>