Skip to content

Commit

Permalink
Fix workflow display with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Joffcom committed Jul 1, 2024
1 parent 3a33088 commit 3b8f3f3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
@@ -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>"

0 comments on commit 3b8f3f3

Please sign in to comment.