feat: Add support for files in plugin outputs
All checks were successful
Build Docker / Build Image (push) Successful in 37s
All checks were successful
Build Docker / Build Image (push) Successful in 37s
This commit is contained in:
parent
fc2ad1682c
commit
1d1aee898f
17
main.py
17
main.py
@ -1,3 +1,4 @@
|
|||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory,send_file
|
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory,send_file
|
||||||
@ -1457,19 +1458,21 @@ def plugin_function(ptype,plugin,function):
|
|||||||
# Handle URL encoding of DNS
|
# Handle URL encoding of DNS
|
||||||
request_data[input] = urllib.parse.unquote(request_data[input])
|
request_data[input] = urllib.parse.unquote(request_data[input])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = plugins_module.runPluginFunction(plugin,function,request_data,request.cookies.get("account"))
|
response = plugins_module.runPluginFunction(plugin,function,request_data,request.cookies.get("account"))
|
||||||
if not response:
|
if not response:
|
||||||
return redirect("/plugin/" + plugin + "?error=An error occurred")
|
return redirect("/plugin/" + plugin + "?error=An error occurred")
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
return redirect("/plugin/" + plugin + "?error=" + response['error'])
|
return redirect("/plugin/" + plugin + "?error=" + response['error'])
|
||||||
|
outputs = plugins_module.getPluginFunctionReturns(plugin,function)
|
||||||
|
# Check outputs
|
||||||
|
for output in outputs:
|
||||||
|
if outputs[output]['type'] == "file":
|
||||||
|
data = io.BytesIO(response[output].encode('utf-8'))
|
||||||
|
return send_file(data, as_attachment=True, download_name=outputs[output]['name'])
|
||||||
|
|
||||||
response = render.plugin_output(response,plugins_module.getPluginFunctionReturns(plugin,function))
|
response = render.plugin_output(response,outputs)
|
||||||
return render_template("plugin-output.html", account=account,
|
return render_template("plugin-output.html", account=account,name=data['name'],
|
||||||
|
description=data['description'],output=response)
|
||||||
name=data['name'],description=data['description'],output=response)
|
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user