Fix workflow display with macro

This commit is contained in:
Jonathan Bennetts 2024-07-01 15:12:17 +01:00
parent 3a33088ed7
commit 3b8f3f382c
No known key found for this signature in database
GPG Key ID: B5F058FEE96F5850

21
main.py
View File

@ -1,13 +1,18 @@
import requests
import html
import urllib.parse
import json
def define_env(env):
"Hook function"
"Hook function"
@env.macro
def workflowDemo(workflow_endpoint):
r = requests.get(url = workflow_endpoint)
workflow_json = r.content.decode("utf-8")
print(workflow_json)
return f"<div class='workflow_preview'><n8n-demo clicktointeract='true' frame='true' collapseformobile='false' workflow='{workflow_json}'></n8n-demo></div>"
@env.macro
def workflowDemo(workflow_endpoint):
r = requests.get(url = workflow_endpoint)
wf_data = r.json()
workflow_json = {
"nodes": wf_data['workflow']['nodes'],
"connections": wf_data['workflow']['connections']
}
encoded_workflow_json = urllib.parse.quote(json.dumps(workflow_json))
return f"<div class='workflow_preview'><n8n-demo clicktointeract='true' frame='true' collapseformobile='false' workflow='{encoded_workflow_json}'></n8n-demo></div>"